private wrappChunks()

in packages/build-tools/breezr-plugin-os/src/OSJsonpPlugin.ts [46:77]


  private wrappChunks(compiler: Compiler, compilation: compilation.Compilation, chunks: compilation.Chunk[]) {
    chunks.forEach((firstChunk) => {
      if (!firstChunk) {
        return;
      }
      const entryFile = firstChunk.files.find((file) => file.endsWith('.js'));
      if (!entryFile) {
        return chunks;
      }

      if (
        this.option.ignoreFilenames?.find(
          (strOrReg) => {
            if (typeof strOrReg === 'string') return strOrReg === entryFile;
            if (strOrReg instanceof RegExp) return strOrReg.test(entryFile);
            return false;
          },
        )
      ) {
        return;
      }

      const entryAsset = compilation.assets[entryFile];
      if (!entryAsset) {
        return;
      }

      const [prefix, suffix] = this._wrapCodeWithOSJsonp(this.option.id || this.getId(compiler));

      compilation.assets[entryFile] = new ConcatSource(prefix, entryAsset, suffix);
    });
  }