Repository: parcel-bundler/parcel
File: packages/transformers/webextension/src/WebExtensionTransformer.js (JavaScript)

Code before:
            bundleBehavior: 'isolated',
            needsStableName: true,
            loc: {
              filePath,
              ...getJSONSourceLocation(
                ptrs[
                  `/web_accessible_resources/${i}${
                    isMV2 ? '' : `/resources/${j}`
                  }`
                ],
              ),
            },
          }),
        );
        currentFiles = currentFiles.concat(globFiles);
      }
      if (isMV2) {
        war = war.concat(currentFiles);
      } else {
        currentEntry.resources = currentFiles;
        war.push(currentEntry);
      }
    }
    program.web_accessible_resources = war;
  }
  if (program.declarative_net_request?.rule_resources) {
    const rrs: {path: string, id: string, enabled: boolean}[] =
      program.declarative_net_request?.rule_resources ?? [];
    for (let i = 0; i < rrs.length; ++i) {
      const resources = rrs[i];
      const rulesPath = path.relative(assetDir, resources.path);
      if (!(await fs.exists(rulesPath))) {
        const pathSourceLoc = getJSONSourceLocation(
          ptrs[`/declarative_net_request/rule_resources/${i}/path`],
          'value',
        );
        throw new ThrowableDiagnostic({
          diagnostic: [
            {
              message: 'Invalid Web Extension manifest',
              origin: '@parcel/transformer-webextension',
              codeFrames: [
                {
                  filePath,
                  language: 'json',
                  codeHighlights: [
                    {
                      ...pathSourceLoc,
                      message: `Path does not exist`,
                    },
                  ],

Review comment (suggestion):
If I'm right that `rule_resources` is a required field you just need to check for `program.declarative_net_request` here.

Code after:
        ).map(fp =>
          asset.addURLDependency(path.relative(assetDir, fp), {
            bundleBehavior: 'isolated',
            needsStableName: true,
            loc: {
              filePath,
              ...getJSONSourceLocation(
                ptrs[
                  `/web_accessible_resources/${i}${
                    isMV2 ? '' : `/resources/${j}`
                  }`
                ],
              ),
            },
          }),
        );
        currentFiles = currentFiles.concat(globFiles);
      }
      if (isMV2) {
        war = war.concat(currentFiles);
      } else {
        currentEntry.resources = currentFiles;
        war.push(currentEntry);
      }
    }
    program.web_accessible_resources = war;
  }
  if (program.declarative_net_request) {
    const rrs: {|path: string, id: string, enabled: boolean|}[] =
      program.declarative_net_request?.rule_resources ?? [];
    rrs.forEach((resources, i) => {
      resources.path = asset.addURLDependency(resources.path, {
        pipeline: 'raw',
        loc: {
          filePath,
          ...getJSONSourceLocation(
            ptrs[`/declarative_net_request/rule_resources/${i}/path`],
            'value',
          ),
        },
      });
    });
  }

  for (const loc of DEP_LOCS) {
    const location = '/' + loc.join('/');
    if (!ptrs[location]) continue;
    let parent: any = program;
    for (let i = 0; i < loc.length - 1; ++i) {
      parent = parent[loc[i]];
    }