@nuxt/webpack-builder 4.1.3 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +25 -16
- package/package.json +11 -10
package/dist/index.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { logger, useNitro, useNuxt } from '@nuxt/kit';
|
|
|
8
8
|
import { createUnplugin } from 'unplugin';
|
|
9
9
|
import MagicString from 'magic-string';
|
|
10
10
|
import { webpack, WebpackBarPlugin, builder, MiniCssExtractPlugin, TsCheckerPlugin } from '#builder';
|
|
11
|
-
import { join, resolve, basename, normalize,
|
|
11
|
+
import { join, resolve, basename, normalize, isAbsolute } from 'pathe';
|
|
12
12
|
import { createFsFromVolume, Volume } from 'memfs';
|
|
13
13
|
import querystring from 'node:querystring';
|
|
14
14
|
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
|
|
@@ -24,8 +24,9 @@ import createResolver from 'postcss-import-resolver';
|
|
|
24
24
|
import { createJiti } from 'jiti';
|
|
25
25
|
import VueLoaderPlugin from 'vue-loader/dist/pluginWebpack5.js';
|
|
26
26
|
import { mkdir, writeFile } from 'node:fs/promises';
|
|
27
|
-
import { normalizeWebpackManifest } from 'vue-bundle-renderer';
|
|
27
|
+
import { normalizeWebpackManifest, precomputeDependencies } from 'vue-bundle-renderer';
|
|
28
28
|
import { hash } from 'ohash';
|
|
29
|
+
import { serialize } from 'seroval';
|
|
29
30
|
|
|
30
31
|
const defaults = {
|
|
31
32
|
globalPublicPath: "__webpack_public_path__",
|
|
@@ -475,6 +476,17 @@ function getEnv(ctx) {
|
|
|
475
476
|
"import.meta.client": ctx.isClient,
|
|
476
477
|
"import.meta.server": ctx.isServer
|
|
477
478
|
};
|
|
479
|
+
if (ctx.isClient) {
|
|
480
|
+
_env["process.prerender"] = false;
|
|
481
|
+
_env["process.nitro"] = false;
|
|
482
|
+
_env["import.meta.prerender"] = false;
|
|
483
|
+
_env["import.meta.nitro"] = false;
|
|
484
|
+
} else {
|
|
485
|
+
_env["process.prerender"] = "(()=>process.prerender)()";
|
|
486
|
+
_env["process.nitro"] = "(()=>process.nitro)()";
|
|
487
|
+
_env["import.meta.prerender"] = "(()=>import.meta.prerender)()";
|
|
488
|
+
_env["import.meta.nitro"] = "(()=>import.meta.nitro)()";
|
|
489
|
+
}
|
|
478
490
|
if (ctx.userConfig.aggressiveCodeRemoval) {
|
|
479
491
|
_env["typeof process"] = JSON.stringify(ctx.isServer ? "object" : "undefined");
|
|
480
492
|
_env["typeof window"] = _env["typeof document"] = JSON.stringify(!ctx.isServer ? "object" : "undefined");
|
|
@@ -703,11 +715,11 @@ async function createPostcssLoadersRule(ctx) {
|
|
|
703
715
|
}
|
|
704
716
|
|
|
705
717
|
class VueSSRClientPlugin {
|
|
706
|
-
|
|
718
|
+
serverDist;
|
|
719
|
+
nuxt;
|
|
707
720
|
constructor(options) {
|
|
708
|
-
this.
|
|
709
|
-
|
|
710
|
-
}, options);
|
|
721
|
+
this.serverDist = resolve(options.nuxt.options.buildDir, "dist/server");
|
|
722
|
+
this.nuxt = options.nuxt;
|
|
711
723
|
}
|
|
712
724
|
apply(compiler) {
|
|
713
725
|
compiler.hooks.afterEmit.tap("VueSSRClientPlugin", async (compilation) => {
|
|
@@ -798,12 +810,12 @@ class VueSSRClientPlugin {
|
|
|
798
810
|
}
|
|
799
811
|
}
|
|
800
812
|
const manifest = normalizeWebpackManifest(webpackManifest);
|
|
801
|
-
await this.
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
await writeFile(this.
|
|
805
|
-
|
|
806
|
-
await writeFile(this.
|
|
813
|
+
await this.nuxt.callHook("build:manifest", manifest);
|
|
814
|
+
await mkdir(this.serverDist, { recursive: true });
|
|
815
|
+
const precomputed = precomputeDependencies(manifest);
|
|
816
|
+
await writeFile(join(this.serverDist, `client.manifest.json`), JSON.stringify(manifest, null, 2));
|
|
817
|
+
await writeFile(join(this.serverDist, "client.manifest.mjs"), "export default " + serialize(manifest), "utf8");
|
|
818
|
+
await writeFile(join(this.serverDist, "client.precomputed.mjs"), "export default " + serialize(precomputed), "utf8");
|
|
807
819
|
});
|
|
808
820
|
}
|
|
809
821
|
}
|
|
@@ -885,10 +897,7 @@ function vue(ctx) {
|
|
|
885
897
|
options: ctx.userConfig.loaders.vue
|
|
886
898
|
});
|
|
887
899
|
if (ctx.isClient) {
|
|
888
|
-
ctx.config.plugins.push(new VueSSRClientPlugin({
|
|
889
|
-
filename: resolve(ctx.options.buildDir, "dist/server", `${ctx.name}.manifest.json`),
|
|
890
|
-
nuxt: ctx.nuxt
|
|
891
|
-
}));
|
|
900
|
+
ctx.config.plugins.push(new VueSSRClientPlugin({ nuxt: ctx.nuxt }));
|
|
892
901
|
} else {
|
|
893
902
|
ctx.config.plugins.push(new VueSSRServerPlugin({
|
|
894
903
|
filename: `${ctx.name}.manifest.json`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxt/webpack-builder",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/nuxt/nuxt.git",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"h3": "^1.15.4",
|
|
40
40
|
"jiti": "^2.6.1",
|
|
41
41
|
"knitwork": "^1.2.0",
|
|
42
|
-
"magic-string": "^0.30.
|
|
43
|
-
"memfs": "^4.
|
|
42
|
+
"magic-string": "^0.30.21",
|
|
43
|
+
"memfs": "^4.49.0",
|
|
44
44
|
"mini-css-extract-plugin": "^2.9.4",
|
|
45
45
|
"ohash": "^2.0.11",
|
|
46
46
|
"pathe": "^2.0.3",
|
|
@@ -51,30 +51,31 @@
|
|
|
51
51
|
"postcss-loader": "^8.2.0",
|
|
52
52
|
"postcss-url": "^10.1.3",
|
|
53
53
|
"pug-plain-loader": "^1.1.0",
|
|
54
|
-
"
|
|
54
|
+
"seroval": "^1.3.2",
|
|
55
|
+
"std-env": "^3.10.0",
|
|
55
56
|
"time-fix-plugin": "^2.0.7",
|
|
56
57
|
"tinyglobby": "^0.2.15",
|
|
57
58
|
"ufo": "^1.6.1",
|
|
58
|
-
"unenv": "^2.0.0-rc.
|
|
59
|
+
"unenv": "^2.0.0-rc.22",
|
|
59
60
|
"unplugin": "^2.3.10",
|
|
60
61
|
"url-loader": "^4.1.1",
|
|
61
62
|
"vue-bundle-renderer": "^2.2.0",
|
|
62
63
|
"vue-loader": "^17.4.2",
|
|
63
|
-
"webpack": "^5.102.
|
|
64
|
+
"webpack": "^5.102.1",
|
|
64
65
|
"webpack-bundle-analyzer": "^4.10.2",
|
|
65
66
|
"webpack-dev-middleware": "^7.4.5",
|
|
66
67
|
"webpack-hot-middleware": "^2.26.1",
|
|
67
68
|
"webpackbar": "^7.0.0",
|
|
68
|
-
"@nuxt/kit": "4.
|
|
69
|
+
"@nuxt/kit": "4.2.0"
|
|
69
70
|
},
|
|
70
71
|
"devDependencies": {
|
|
71
72
|
"@rspack/core": "1.5.8",
|
|
72
73
|
"@types/webpack-bundle-analyzer": "4.7.0",
|
|
73
|
-
"@types/webpack-hot-middleware": "2.25.
|
|
74
|
-
"rollup": "4.52.
|
|
74
|
+
"@types/webpack-hot-middleware": "2.25.11",
|
|
75
|
+
"rollup": "4.52.5",
|
|
75
76
|
"unbuild": "3.6.1",
|
|
76
77
|
"vue": "3.5.22",
|
|
77
|
-
"@nuxt/schema": "4.
|
|
78
|
+
"@nuxt/schema": "4.2.0"
|
|
78
79
|
},
|
|
79
80
|
"peerDependencies": {
|
|
80
81
|
"vue": "^3.3.4"
|