Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
logger.progress(`Packaging...`);
// Package everything up
this.bundleHashes = await this.mainBundle.package(
this,
bundlesChanged ? null : this.bundleHashes,
);
// Unload any orphaned assets
this.unloadOrphanedAssets();
let buildTime = Date.now() - startTime;
let time = prettifyTime(buildTime);
logger.success(`Built in ${time}.`);
if (!this.watcher) {
bundleReport(this.mainBundle, this.options.detailedReport);
}
this.emit('bundled', this.mainBundle);
return this.mainBundle;
} catch (err) {
this.error = err;
logger.error(err);
this.emit('buildError', err);
if (this.hmr) {
this.hmr.emitError(err);
}
}
logger.progress(`Packaging...`);
// Package everything up
this.bundleHashes = await this.mainBundle.package(
this,
this.bundleHashes
);
// Unload any orphaned assets
this.unloadOrphanedAssets();
let buildTime = Date.now() - startTime;
let time = prettifyTime(buildTime);
logger.success(`Built in ${time}.`);
if (!this.watcher) {
bundleReport(this.mainBundle, this.options.detailedReport);
}
this.emit('bundled', this.mainBundle);
return this.mainBundle;
} catch (err) {
this.error = err;
logger.error(err);
this.emit('buildError', err);
if (this.hmr) {
this.hmr.emitError(err);
}
if (ind === -1) {
const htmlInd = origHTML.search(htmlSearch);
if (htmlInd === -1) {
throw 'HTML file for link injection is invalid.';
}
origHTML = `${origHTML.slice(0, htmlInd)}<title>${
generator.manifest.name
}</title>${html}${origHTML.slice(htmlInd)}`;
} else {
origHTML = `${origHTML.slice(0, ind)}${html}${origHTML
.slice(ind)
.replace(oldInjectionSearch, '')}`;
}
writeFileSync(filename, origHTML);
}
logger.success('Manifest creation successful.');
bundler.emit('pwaBuildEnd');
};
bundler.on('bundled', async bundle => {