Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const ramModules = modules.map(module => ({
id: module.id,
code: module.code,
map: fromRawMappings([module]).toMap(module.path, {
excludeSource: options.excludeSource,
}),
name: module.name,
sourcePath: module.path,
source: module.source,
type: module.type,
}));
async function fullSourceMap(
deltaBundler: DeltaBundler,
options: BundleOptions,
): Promise {
const {modules} = await _getAllModules(deltaBundler, options);
return fromRawMappings(modules).toString(undefined, {
excludeSource: options.excludeSource,
});
}
async _minifyCode(
filename: string,
code: string,
source: string,
map: Array,
reserved?: $ReadOnlyArray = [],
): Promise<{
code: string,
map: Array,
...
}> {
const sourceMap = fromRawMappings([
{code, source, map, functionMap: null, path: filename},
]).toMap(undefined, {});
const minify = getMinifier(this._config.minifierPath);
try {
const minified = minify({
code,
map: sourceMap,
filename,
reserved,
config: this._config.minifierConfig,
});
return {
code: minified.code,
async function fullSourceMapObject(
deltaBundler: DeltaBundler,
options: BundleOptions,
): Promise {
const {modules} = await _getAllModules(deltaBundler, options);
return fromRawMappings(modules).toMap(undefined, {
excludeSource: options.excludeSource,
});
}
): ReturnType {
let sourceMapInfos;
getSourceMapInfosImpl(
true,
infos => {
sourceMapInfos = infos;
},
modules,
options,
);
if (sourceMapInfos == null) {
throw new Error(
'Expected getSourceMapInfosImpl() to finish synchronously.',
);
}
return fromRawMappings(sourceMapInfos);
}
async minifyModule(
path: string,
code: string,
map: CompactRawMappings,
): Promise<{code: string, map: CompactRawMappings}> {
const sourceMap = fromRawMappings([{code, source: code, map, path}]).toMap(
undefined,
{},
);
const minified = await this._minifyCode(path, code, sourceMap);
const result = await this._postMinifyProcess({...minified});
return {
code: result.code,
map: result.map ? toRawMappings(result.map).map(compactMapping) : [],
};
}