Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.plugin("render", (bootstrapSource, chunk, hash, moduleTemplate, dependencyTemplates) => {
const source = new ConcatSource();
source.add("/******/ (function(modules) { // webpackBootstrap\n");
source.add(new PrefixSource("/******/", bootstrapSource));
source.add("/******/ })\n");
source.add("/************************************************************************/\n");
source.add("/******/ (");
const modules = this.renderChunkModules(chunk, moduleTemplate, dependencyTemplates, "/******/ ");
source.add(this.applyPluginsWaterfall("modules", modules, chunk, hash, moduleTemplate, dependencyTemplates));
source.add(")");
return source;
});
this.plugin("local-vars", (source, chunk, hash) => {
Object.keys(assets).forEach(name => {
const asset = assets[name]
const map = asset.map()
if (map) {
// make sure sources in the source map are timestamped, this helps with hot reloading
const now = Date.now()
map.sources = map.sources.map(source => source + (source.includes('?') ? '&' : '?') + now)
const [startComment, endComment] = name.endsWith('.css') ? ['/*', ' */'] : ['//', '']
assets[name] = new ConcatSource(asset, `\n${startComment}# sourceMappingURL=${path.basename(name)}.map${endComment}\n`)
assets[name + '.map'] = new RawSource(JSON.stringify(map))
}
})
})
chunkTemplate.plugin('render', function (modules, chunk) {
const jsonpFunction = this.outputOptions.jsonpFunction;
const source = new ConcatSource();
source.add(`${jsonpFunction}(${JSON.stringify(chunk.ids)},`);
source.add(modules);
const entries = [ chunk.entryModule ].filter(Boolean).map(m => m.id);
if (entries.length > 0) {
source.add(`,${JSON.stringify(entries)}`);
}
source.add(')');
return source;
});
chunkTemplate.plugin('hash', function (hash) {
compilation.templatesPlugin("render-with-entry", (source, chunk, hash) => {
const varExpression = mainTemplate.applyPluginsWaterfall("asset-path", this.varExpression, {
hash,
chunk
});
if(this.copyObject) {
return new ConcatSource(`(function(e, a) { for(var i in a) e[i] = a[i]; }(${varExpression}, `, source, "))");
} else {
const prefix = `${varExpression} =\n`;
return new ConcatSource(prefix, source);
}
});
mainTemplate.plugin("global-hash-paths", (paths) => {
compilation.hooks.afterOptimizeChunkAssets.tap('ESModulePlugin', (chunks) => {
for (const chunk of chunks) {
if (!chunk.canBeInitial()) {
continue
}
for (const file of chunk.files) {
compilation.assets[file] = new ConcatSource(
compilation.assets[file],
'\n',
`export default ${this.options.exportedMember};`
)
}
}
})
})
basename = filename;
} else {
basename = filename.substr(lastSlashIndex + 1);
}
const data = {
hash,
chunk,
filename,
basename,
query
};
const comment = compilation.getPath(banner(data), data);
compilation.assets[file] = new ConcatSource(
comment,
"\n",
compilation.assets[file]
);
}
}
});
});
if (config.options?.template) {
const key = c.name + '.wxml'
compilation.assets[key] = compilation.assets[key]
? new ConcatSource(compilation.assets[key], '\n', config.content)
: new ConcatSource(config.content)
} else if (config.options?.stylesheets || config.__MINA?.options.stylesheets) {
const key = 'app.wxss'
if (config.__MINA?.options.cssModules) {
compilation.assets[key] = compilation.assets[key]
? new ConcatSource(compilation.assets[key], '\n', config.__MINA.stylesheets)
: new ConcatSource(config.__MINA.stylesheets)
} else {
compilation.assets[key] = compilation.assets[key]
? new ConcatSource(compilation.assets[key], '\n', config.content)
: new ConcatSource(config.content)
}
}
}
}
}
}
}
}
let amdFactory;
if(optionalExternals.length > 0) {
const wrapperArguments = externalsArguments(requiredExternals);
const factoryArguments = requiredExternals.length > 0 ?
externalsArguments(requiredExternals) + ", " + externalsRootArray(optionalExternals) :
externalsRootArray(optionalExternals);
amdFactory = `function webpackLoadOptionalExternalModuleAmd(${wrapperArguments}) {\n` +
` return factory(${factoryArguments});\n` +
" }";
} else {
amdFactory = "factory";
}
return new ConcatSource(new OriginalSource(
"(function webpackUniversalModuleDefinition(root, factory) {\n" +
(this.auxiliaryComment &&
typeof this.auxiliaryComment === "string" ?
" //" + this.auxiliaryComment + "\n" :
this.auxiliaryComment.commonjs2 ?
" //" + this.auxiliaryComment.commonjs2 + "\n" :
""
) +
" if(typeof exports === 'object' && typeof module === 'object')\n" +
" module.exports = factory(" + externalsRequireArray("commonjs2") + ");\n" +
(this.auxiliaryComment &&
typeof this.auxiliaryComment === "string" ?
" //" + this.auxiliaryComment + "\n" :
this.auxiliaryComment.amd ?
" //" + this.auxiliaryComment.amd + "\n" :
""
compilation.assets[asset] = new _webpackSources.ConcatSource(output.css);
});
if (match) {
var rtlMinify = _cssnano2.default.process(rtlSource, nanoOptions).then(function (output) {
compilation.assets[filename] = new _webpackSources.ConcatSource(output.css);
rtlFiles.push(filename);
});
minify = Promise.all([minify, rtlMinify]);
}
return minify;
});
} else if (match) {
compilation.assets[filename] = new _webpackSources.ConcatSource(rtlSource);
rtlFiles.push(filename);
}
});
compilation.hooks.additionalAssets.tapAsync('MiniPlugin', callback => {
compilation.assets['webpack-require.js'] = new ConcatSource(
fs.readFileSync(join(__dirname, './lib/require.js'), 'utf8')
)
callback()
})