How to use the webpack-sources.RawSource function in webpack-sources

To help you get started, we’ve selected a few webpack-sources examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github flaviuse / mern-authentication / client / node_modules / webpack / lib / wasm / WebAssemblyJavascriptGenerator.js View on Github external
Array.from(
				importedModules,
				([module, { importVar, request, reexports }]) => {
					const importStatement = runtimeTemplate.importStatement({
						module,
						request,
						importVar,
						originModule: module
					});
					return importStatement + reexports.join("\n");
				}
			)
		);

		// create source
		const source = new RawSource(
			[
				'"use strict";',
				"// Instantiate WebAssembly module",
				"var wasmExports = __webpack_require__.w[module.i];",

				!Array.isArray(module.usedExports)
					? `__webpack_require__.r(${module.exportsArgument});`
					: "",

				// this must be before import for circular dependencies
				"// export exports from WebAssembly module",
				Array.isArray(module.usedExports) && !needExportsCopy
					? `${module.moduleArgument}.exports = wasmExports;`
					: "for(var name in wasmExports) " +
					  `if(name != ${JSON.stringify(initIdentifer)}) ` +
					  `${module.exportsArgument}[name] = wasmExports[name];`,
github realywithoutname / mini-program-webpack-loader / src / MiniProgram.js View on Github external
if (this.options.target === 'ali') {
      ext = '.acss'
      wxssCode += `
        /* polyfill */
        ${readFileSync(join(__dirname, './ali/lib/base.acss'), 'utf8')}
      `
    }

    entryNames.forEach((name) => {
      let code = compilation.assets[name + ext]
      if (code) {
        wxssCode += `/************ ${name + ext} *************/\n`
        wxssCode += code.source().toString()
      }
    })
    return new RawSource(wxssCode)
  }
github angular / angular-cli / packages / angular_devkit / build_angular / src / angular-cli-files / plugins / cleancss-webpack-plugin.ts View on Github external
if (hasWarnings && output.stats.minifiedSize === 0) {
            return;
          }

          let newSource;
          if (output.sourceMap) {
            newSource = new SourceMapSource(
              output.styles,
              file,
              // tslint:disable-next-line: no-any
              output.sourceMap.toString() as any,
              content,
              map,
            );
          } else {
            newSource = new RawSource(output.styles);
          }

          compilation.assets[file] = newSource;
        });
github kaliberjs / build / library / webpack-plugins / react-universal-plugin.js View on Github external
compilation.hooks.additionalChunkAssets.tap(p, chunks => {
          const entryManifest = chunks
            .filter(x => x.name)
            .reduce((result, x) => {
              const names = getJavascriptChunkNames(x, compiler)
              return names.length ? { ...result, [x.name]: names } : result
            }, {})

          compilation.assets['entry-manifest.json'] = new RawSource(JSON.stringify(entryManifest, null, 2))
        })
      })
github sysgears / create-apollo-app / packages / spinjs / src / executor.ts View on Github external
chunk.files.forEach(file => {
          if (file.endsWith('.bundle')) {
            if (builder.sourceMap) {
              const sourceListMap = new SourceListMap();
              sourceListMap.add(vendorSourceListMap);
              sourceListMap.add(
                fromStringWithSourceMap(
                  compilation.assets[file].source(),
                  JSON.parse(compilation.assets[file + '.map'].source())
                )
              );
              const sourceAndMap = sourceListMap.toStringWithSourceMap({ file });
              compilation.assets[file] = new RawSource(sourceAndMap.source);
              compilation.assets[file + '.map'] = new RawSource(JSON.stringify(sourceAndMap.map));
            } else {
              compilation.assets[file] = new ConcatSource(vendorSource, compilation.assets[file]);
            }
          }
        });
      });
github GoogleChromeLabs / critters / src / index.js View on Github external
.then(html => {
              assets[htmlAssetName] = new sources.RawSource(html);
              callback();
            })
            .catch(callback);
github eschirtz / Computer-Science-Series / node_modules / webpack / lib / SourceMapDevToolPlugin.js View on Github external
sourceMapUrl
									)
								);
							}
							assets[sourceMapFile] = compilation.assets[
								sourceMapFile
							] = new RawSource(sourceMapString);
							chunk.files.push(sourceMapFile);
						} else {
							if (currentSourceMappingURLComment === false) {
								throw new Error(
									"SourceMapDevToolPlugin: append can't be false when no filename is provided"
								);
							}
							assets[file] = compilation.assets[file] = new ConcatSource(
								new RawSource(source),
								currentSourceMappingURLComment
									.replace(/\[map\]/g, () => sourceMapString)
									.replace(
										/\[url\]/g,
										() =>
											`data:application/json;charset=utf-8;base64,${Buffer.from(
												sourceMapString,
												"utf-8"
											).toString("base64")}`
									)
							);
						}
					});
					reportProgress(1.0);
github zeit / next.js / packages / next / build / webpack / plugins / css-minimizer-plugin.ts View on Github external
return minify(input, postcssOptions).then(res => {
                  if (res.map) {
                    compilation.assets[file] = new SourceMapSource(
                      res.css,
                      file,
                      res.map.toJSON()
                    )
                  } else {
                    compilation.assets[file] = new RawSource(res.css)
                  }
                })
              })
github sysgears / create-apollo-app / packages / spinjs / src / executor.ts View on Github external
})
    );
    vendorHashesJson = JSON.parse(
      fs.readFileSync(path.join(builder.dllBuildDir, `${name}_dll_hashes.json`)).toString()
    );
    vendorSource = new RawSource(
      fs.readFileSync(path.join(builder.dllBuildDir, vendorHashesJson.name)).toString() + '\n'
    );
    if (platform !== 'web') {
      const vendorAssets = JSON.parse(
        fs.readFileSync(path.join(builder.dllBuildDir, vendorHashesJson.name + '.assets')).toString()
      );
      config.plugins.push(new MobileAssetsPlugin(vendorAssets));
    }
    if (builder.sourceMap) {
      vendorMap = new RawSource(
        fs.readFileSync(path.join(builder.dllBuildDir, vendorHashesJson.name + '.map')).toString()
      );
      vendorSourceListMap = fromStringWithSourceMap(vendorSource.source(), JSON.parse(vendorMap.source()));
    }
  }

  const compiler = webpack(config);
  let awaitedAlready = false;

  hookAsync(compiler, 'after-emit', (compilation, callback) => {
    if (!awaitedAlready) {
      if (hasBackend || builder.waitOn) {
        let waitOnUrls;
        const backendOption = builder.backendUrl || builder.backendUrl;
        if (backendOption) {
          const { protocol, hostname, port } = url.parse(backendOption.replace('{ip}', ip.address()));