🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

@prerenderer/webpack-plugin

Package Overview
Dependencies
Maintainers
2
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prerenderer/webpack-plugin - npm Package Compare versions

Comparing version

to
5.3.5

52

dist/WebpackPrerenderSPAPlugin.js

@@ -52,3 +52,3 @@ "use strict";

}
prerender(compiler, compilation) {
prerender(compiler, compilation, alreadyRenderedRoutes = []) {
return __awaiter(this, void 0, void 0, function* () {

@@ -114,26 +114,32 @@ const indexPath = this.options.indexPath;

try {
yield PrerendererInstance.initialize();
const renderedRoutes = yield PrerendererInstance.renderRoutes(this.options.routes || []);
// Calculate outputPath if it hasn't been set already.
renderedRoutes.forEach(processedRoute => {
// Create dirs and write prerendered files.
if (!processedRoute.outputPath) {
processedRoute.outputPath = path_1.default.join(processedRoute.route, indexPath);
if (processedRoute.outputPath.startsWith('/') || processedRoute.outputPath.startsWith('\\')) {
processedRoute.outputPath = processedRoute.outputPath.slice(1);
const routes = [...new Set(this.options.routes || [])];
if (routes.length) {
yield PrerendererInstance.initialize();
const renderedRoutes = yield PrerendererInstance.renderRoutes(routes);
alreadyRenderedRoutes.concat(routes);
// Calculate outputPath if it hasn't been set already.
renderedRoutes.forEach(processedRoute => {
// Create dirs and write prerendered files.
if (!processedRoute.outputPath) {
processedRoute.outputPath = path_1.default.join(processedRoute.route, indexPath);
if (processedRoute.outputPath.startsWith('/') || processedRoute.outputPath.startsWith('\\')) {
processedRoute.outputPath = processedRoute.outputPath.slice(1);
}
}
}
if (processedRoute.outputPath in compilation.assets && this.options.fallback) {
const fallback = typeof this.options.fallback === 'string' ? this.options.fallback : '_fallback';
const ext = path_1.default.extname(processedRoute.outputPath);
const fileName = processedRoute.outputPath.slice(0, -ext.length) + fallback + ext;
compilation.emitAsset(fileName, compilation.assets[processedRoute.outputPath]);
}
// false positive as calling call(compilation) right after
// eslint-disable-next-line @typescript-eslint/unbound-method
const fn = processedRoute.outputPath in compilation.assets ? compilation.updateAsset : compilation.emitAsset;
fn.call(compilation, processedRoute.outputPath, new compiler.webpack.sources.RawSource(processedRoute.html.trim(), false), {
prerendered: true,
if (processedRoute.outputPath in compilation.assets && this.options.fallback) {
const fallback = typeof this.options.fallback === 'string' ? this.options.fallback : '_fallback';
const ext = path_1.default.extname(processedRoute.outputPath);
const fileName = processedRoute.outputPath.slice(0, -ext.length) + fallback + ext;
if (!(fileName in compilation.assets)) {
compilation.emitAsset(fileName, compilation.assets[processedRoute.outputPath]);
}
}
// false positive as calling call(compilation) right after
// eslint-disable-next-line @typescript-eslint/unbound-method
const fn = processedRoute.outputPath in compilation.assets ? compilation.updateAsset : compilation.emitAsset;
fn.call(compilation, processedRoute.outputPath, new compiler.webpack.sources.RawSource(processedRoute.html.trim(), false), {
prerendered: true,
});
});
});
}
}

@@ -140,0 +146,0 @@ catch (err) {

{
"name": "@prerenderer/webpack-plugin",
"version": "5.3.4",
"version": "5.3.5",
"description": "Flexible, framework-agnostic static site generation for apps built with webpack.",

@@ -66,7 +66,7 @@ "license": "MIT",

"dependencies": {
"@prerenderer/prerenderer": "^1.2.1",
"@prerenderer/prerenderer": "^1.2.2",
"schema-utils": "^4.0.0"
},
"optionalDependencies": {
"@prerenderer/renderer-puppeteer": "^1.1.6"
"@prerenderer/renderer-puppeteer": "^1.2.1"
},

@@ -79,3 +79,3 @@ "peerDependencies": {

"@prerenderer/prerenderer": "file:../prerenderer",
"@prerenderer/renderer-jsdom": "^1.1.4",
"@prerenderer/renderer-jsdom": "^1.1.5",
"@prerenderer/renderer-puppeteer": "file:../renderer-puppeteer",

@@ -93,3 +93,3 @@ "express": "^4.18.2",

},
"gitHead": "eefab0a219bb0e7ecb267c243c13ac1a627c9e72"
"gitHead": "a9d564e6ea269990cf9effb6d53840553ee8d8bc"
}

@@ -6,4 +6,4 @@ import { WebpackPrerenderSPAOptions } from './Options';

constructor(options?: WebpackPrerenderSPAOptions);
prerender(compiler: Compiler, compilation: Compilation): Promise<false | undefined>;
prerender(compiler: Compiler, compilation: Compilation, alreadyRenderedRoutes?: Array<string>): Promise<false | undefined>;
apply(compiler: Compiler): void;
}