@nuxt/webpack-builder 4.0.0-0 → 4.0.0-alpha.1

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.
Files changed (2) hide show
  1. package/dist/index.mjs +22 -8
  2. package/package.json +11 -11
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import pify from 'pify';
2
- import { join, resolve, normalize, dirname, isAbsolute } from 'pathe';
2
+ import { join, resolve, basename, normalize, dirname, isAbsolute } from 'pathe';
3
3
  import { fromNodeMiddleware, defineEventHandler, handleCors, getRequestHeader, createError, setHeader } from 'h3';
4
4
  import webpackDevMiddleware from 'webpack-dev-middleware';
5
5
  import webpackHotMiddleware from 'webpack-hot-middleware';
@@ -271,11 +271,14 @@ function basePlugins(ctx) {
271
271
  function baseAlias(ctx) {
272
272
  ctx.alias = {
273
273
  "#app": ctx.options.appDir,
274
+ [basename(ctx.nuxt.options.dir.assets)]: resolve(ctx.nuxt.options.srcDir, ctx.nuxt.options.dir.assets),
274
275
  ...ctx.options.alias,
275
276
  ...ctx.alias
276
277
  };
277
278
  if (ctx.isClient) {
278
279
  ctx.alias["nitro/runtime"] = resolve(ctx.nuxt.options.buildDir, "nitro.client.mjs");
280
+ ctx.alias["#internal/nitro"] = resolve(ctx.nuxt.options.buildDir, "nitro.client.mjs");
281
+ ctx.alias["nitropack/runtime"] = resolve(ctx.nuxt.options.buildDir, "nitro.client.mjs");
279
282
  }
280
283
  }
281
284
  function baseResolve(ctx) {
@@ -967,13 +970,18 @@ function serverStandalone(ctx) {
967
970
  "#",
968
971
  ...ctx.options.build.transpile
969
972
  ];
970
- const external = [
973
+ const external = /* @__PURE__ */ new Set([
971
974
  "nitro/runtime",
975
+ // TODO: remove in v5
976
+ "#internal/nitro",
977
+ "nitropack/runtime",
972
978
  "#shared",
973
979
  resolve(ctx.nuxt.options.rootDir, ctx.nuxt.options.dir.shared)
974
- ];
980
+ ]);
975
981
  if (!ctx.nuxt.options.dev) {
976
- external.push("#internal/nuxt/paths", "#internal/nuxt/app-config", "#app-manifest");
982
+ external.add("#internal/nuxt/paths");
983
+ external.add("#internal/nuxt/app-config");
984
+ external.add("#app-manifest");
977
985
  }
978
986
  if (!Array.isArray(ctx.config.externals)) {
979
987
  return;
@@ -982,7 +990,7 @@ function serverStandalone(ctx) {
982
990
  if (!request) {
983
991
  return cb(void 0, false);
984
992
  }
985
- if (external.includes(request)) {
993
+ if (external.has(request)) {
986
994
  return cb(void 0, true);
987
995
  }
988
996
  if (request[0] === "." || isAbsolute(request) || inline.find((prefix) => typeof prefix === "string" && request.startsWith(prefix)) || assetPattern.test(request)) {
@@ -1011,6 +1019,7 @@ const HELPER_DYNAMIC = `\0${PLUGIN_NAME}.mjs`;
1011
1019
  const DYNAMIC_REQUIRE_RE = /import\((?:.*\+\s*)?"\.\/" ?\+(.*)\).then/g;
1012
1020
  const BACKWARD_SLASH_RE = /\\/g;
1013
1021
  function dynamicRequire({ dir, ignore, inline }) {
1022
+ const filesToIgnore = new Set(ignore);
1014
1023
  return {
1015
1024
  name: PLUGIN_NAME,
1016
1025
  transform(code, _id) {
@@ -1038,7 +1047,7 @@ function dynamicRequire({ dir, ignore, inline }) {
1038
1047
  let files = [];
1039
1048
  try {
1040
1049
  const wpManifest = resolve(dir, "./server.manifest.json");
1041
- files = await importModule(wpManifest).then((r) => Object.keys(r.files).filter((file) => !ignore.includes(file)));
1050
+ files = await importModule(wpManifest).then((r) => Object.keys(r.files).filter((file) => !filesToIgnore.has(file)));
1042
1051
  } catch {
1043
1052
  files = await glob("**/*.{cjs,mjs,js}", {
1044
1053
  cwd: dir,
@@ -1113,8 +1122,13 @@ const bundle = async (nuxt) => {
1113
1122
  });
1114
1123
  const prerenderRollupPlugins = nitro.options._config.rollupConfig.plugins;
1115
1124
  const rollupPlugins = nitro.options.rollupConfig.plugins;
1116
- prerenderRollupPlugins.push(dynamicRequirePlugin);
1117
- rollupPlugins.push(dynamicRequirePlugin);
1125
+ for (const plugins of [prerenderRollupPlugins, rollupPlugins]) {
1126
+ const existingPlugin = plugins.findIndex((i) => i && "name" in i && i.name === "dynamic-require");
1127
+ if (existingPlugin >= 0) {
1128
+ plugins.splice(existingPlugin, 1);
1129
+ }
1130
+ plugins.push(dynamicRequirePlugin);
1131
+ }
1118
1132
  }
1119
1133
  await nuxt.callHook(`${builder}:config`, webpackConfigs);
1120
1134
  const mfs = nuxt.options.dev ? createMFS() : null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/webpack-builder",
3
- "version": "4.0.0-0",
3
+ "version": "4.0.0-alpha.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/nuxt/nuxt.git",
@@ -40,12 +40,12 @@
40
40
  "jiti": "^2.4.2",
41
41
  "knitwork": "^1.2.0",
42
42
  "magic-string": "^0.30.17",
43
- "memfs": "^4.17.1",
43
+ "memfs": "^4.17.2",
44
44
  "mini-css-extract-plugin": "^2.9.2",
45
45
  "ohash": "^2.0.11",
46
46
  "pathe": "^2.0.3",
47
47
  "pify": "^6.1.0",
48
- "postcss": "^8.5.3",
48
+ "postcss": "^8.5.4",
49
49
  "postcss-import": "^16.1.0",
50
50
  "postcss-import-resolver": "^2.0.0",
51
51
  "postcss-loader": "^8.1.1",
@@ -53,10 +53,10 @@
53
53
  "pug-plain-loader": "^1.1.0",
54
54
  "std-env": "^3.9.0",
55
55
  "time-fix-plugin": "^2.0.7",
56
- "tinyglobby": "^0.2.13",
56
+ "tinyglobby": "^0.2.14",
57
57
  "ufo": "^1.6.1",
58
- "unenv": "^2.0.0-rc.15",
59
- "unplugin": "^2.3.3",
58
+ "unenv": "^2.0.0-rc.17",
59
+ "unplugin": "^2.3.5",
60
60
  "url-loader": "^4.1.1",
61
61
  "vue-bundle-renderer": "^2.1.1",
62
62
  "vue-loader": "^17.4.2",
@@ -65,16 +65,16 @@
65
65
  "webpack-dev-middleware": "^7.4.2",
66
66
  "webpack-hot-middleware": "^2.26.1",
67
67
  "webpackbar": "^7.0.0",
68
- "@nuxt/kit": "4.0.0-0"
68
+ "@nuxt/kit": "4.0.0-alpha.1"
69
69
  },
70
70
  "devDependencies": {
71
- "@rspack/core": "1.3.9",
71
+ "@rspack/core": "1.3.13",
72
72
  "@types/webpack-bundle-analyzer": "4.7.0",
73
73
  "@types/webpack-hot-middleware": "2.25.9",
74
- "rollup": "4.40.2",
74
+ "rollup": "4.41.1",
75
75
  "unbuild": "3.5.0",
76
- "vue": "3.5.13",
77
- "@nuxt/schema": "4.0.0-0"
76
+ "vue": "3.5.16",
77
+ "@nuxt/schema": "4.0.0-alpha.1"
78
78
  },
79
79
  "peerDependencies": {
80
80
  "vue": "^3.3.4"