Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async handleEmit(compilation, readFile) {
const workboxSWImports = getWorkboxSWImports(compilation, this.config);
let entries = getManifestEntriesFromCompilation(compilation, this.config);
const sanitizedConfig = sanitizeConfig.forGetManifest(this.config);
// If there are any "extra" config options remaining after we remove the
// ones that are used natively by the plugin, then assume that they should
// be passed on to workbox-build.getManifest() to generate extra entries.
if (Object.keys(sanitizedConfig).length > 0) {
// If globPatterns isn't explicitly set, then default to [], instead of
// the workbox-build.getManifest() default.
sanitizedConfig.globPatterns = sanitizedConfig.globPatterns || [];
const {manifestEntries} = await getManifest(sanitizedConfig);
entries = entries.concat(manifestEntries);
}
const manifestString = stringifyManifest(entries);
const manifestAsset = convertStringToAsset(manifestString);
const manifestHash = getAssetHash(manifestAsset);
const manifestFilename = `precache-manifest.${manifestHash}.js`;
compilation.assets[manifestFilename] = manifestAsset;
this.config.importScripts.push(manifestFilename);
// workboxSWImports might be null if importWorkboxFrom is 'disabled'.
if (workboxSWImports) {
// workboxSWImport is an array, so use concat() rather than push().
this.config.importScripts = this.config.importScripts.concat(
workboxSWImports);
}
` InjectManifest. Please use 'cdn' or a chunk name instead.`);
}
const workboxSWImports = await getWorkboxSWImports(
compilation, this.config);
let entries = getManifestEntriesFromCompilation(compilation, this.config);
const sanitizedConfig = sanitizeConfig.forGetManifest(this.config);
// If there are any "extra" config options remaining after we remove the
// ones that are used natively by the plugin, then assume that they should
// be passed on to workbox-build.getManifest() to generate extra entries.
if (Object.keys(sanitizedConfig).length > 0) {
// If globPatterns isn't explicitly set, then default to [], instead of
// the workbox-build.getManifest() default.
sanitizedConfig.globPatterns = sanitizedConfig.globPatterns || [];
const {manifestEntries} = await getManifest(sanitizedConfig);
entries = entries.concat(manifestEntries);
}
const manifestString = stringifyManifest(entries);
const manifestAsset = convertStringToAsset(manifestString);
const manifestHash = getAssetHash(manifestAsset);
let manifestFilename = `precache-manifest.${manifestHash}.js`;
if (this.config.manifestFilename) {
manifestFilename = this.config.manifestFilename.replace('[manifest]', manifestFilename);
}
compilation.assets[manifestFilename] = manifestAsset;
compilation.assets['static/js/' + manifestFilename] = manifestAsset;
this.config.importScripts.push(
(compilation.options.output.publicPath || '') + manifestFilename);
let mergeGeneratedManifests = async (base, overrides) => {
let baseFiles = await swBuild.getManifest(base);
let overrideFiles = [];
if(!overrides.globDirectory) overrideFiles = await swBuild.getManifest(overrides);
let baseFileMap = new Map(baseFiles.manifestEntries.map(entry => [entry.url, entry.revision]));
let overrideFileMap = new Map(overrideFiles.manifestEntries.map(entry => [entry.url, entry.revision]));
let finalManifest = [];
new Map([...baseFileMap, ...overrideFileMap]).forEach((value, key) => finalManifest.push({ url: key, revision: value}));
return finalManifest;
};
let mergeGeneratedManifests = async (base, overrides) => {
let baseFiles = await swBuild.getManifest(base);
let overrideFiles = [];
if(!overrides.globDirectory) overrideFiles = await swBuild.getManifest(overrides);
let baseFileMap = new Map(baseFiles.manifestEntries.map(entry => [entry.url, entry.revision]));
let overrideFileMap = new Map(overrideFiles.manifestEntries.map(entry => [entry.url, entry.revision]));
let finalManifest = [];
new Map([...baseFileMap, ...overrideFileMap]).forEach((value, key) => finalManifest.push({ url: key, revision: value}));
return finalManifest;
};