UNPKG

webpack-target-webextension

Version:

WebExtension plugin for Webpack. Supports code-splitting and dynamic import.

25 lines (24 loc) 702 B
// @ts-check /** * @param {import('webpack')} webpack */ module.exports = function createEagerlyLoadChunksRuntimeModule(webpack) { const { RuntimeGlobals, RuntimeModule, Template } = webpack class EagerlyLoadChunksRuntimeModule extends RuntimeModule { /** * @param {(string | number | null)[]} chunks */ constructor(chunks) { super('eagerly load chunks', RuntimeModule.STAGE_TRIGGER) this.chunks = chunks } generate() { return Template.asString( this.chunks .filter((x) => x !== null) .map((x) => `${RuntimeGlobals.ensureChunkHandlers}.i(${JSON.stringify(x)});`), ) } } return EagerlyLoadChunksRuntimeModule }