@nuxt/webpack-builder-nightly 4.3.0-29443617.eabd3fee → 4.3.0-29444675.2f04ec3a

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 CHANGED
@@ -8,7 +8,7 @@ import { logger, tryImportModule, directoryToURL, resolveAlias, useNitro, useNux
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, isAbsolute } from 'pathe';
11
+ import { join, resolve, basename, normalize, relative, 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';
@@ -23,12 +23,12 @@ import CssMinimizerPlugin from 'css-minimizer-webpack-plugin';
23
23
  import createResolver from 'postcss-import-resolver';
24
24
  import { createJiti } from 'jiti';
25
25
  import VueLoaderPlugin from 'vue-loader/dist/pluginWebpack5.js';
26
+ import { resolveModulePath } from 'exsolve';
26
27
  import { mkdir, writeFile } from 'node:fs/promises';
27
28
  import { normalizeWebpackManifest, precomputeDependencies } from 'vue-bundle-renderer';
28
29
  import { hash } from 'ohash';
29
30
  import { serialize } from 'seroval';
30
31
  import { parseNodeModulePath } from 'mlly';
31
- import { resolveModulePath } from 'exsolve';
32
32
  import { runtimeDependencies } from 'nuxt/meta';
33
33
 
34
34
  const defaults = {
@@ -734,9 +734,15 @@ class VueSSRClientPlugin {
734
734
  this.serverDist = resolve(options.nuxt.options.buildDir, "dist/server");
735
735
  this.nuxt = options.nuxt;
736
736
  }
737
+ getRelativeModuleId(identifier, context) {
738
+ const id = identifier.replace(/\s\w+$/, "");
739
+ const resourceMatch = id.match(/([^!]*\.vue)(?:\?|$)/);
740
+ return resourceMatch && resourceMatch[1] ? normalize(relative(context, resourceMatch[1])).replace(/^\.\//, "").replace(/\\/g, "/") : id;
741
+ }
737
742
  apply(compiler) {
738
743
  compiler.hooks.afterEmit.tap("VueSSRClientPlugin", async (compilation) => {
739
744
  const stats = compilation.getStats().toJson();
745
+ const context = this.nuxt.options.srcDir;
740
746
  const initialFiles = /* @__PURE__ */ new Set();
741
747
  for (const { assets } of Object.values(stats.entrypoints)) {
742
748
  if (!assets) {
@@ -788,7 +794,7 @@ class VueSSRClientPlugin {
788
794
  if (!chunk || !chunk.files || !cid) {
789
795
  continue;
790
796
  }
791
- const id = m.identifier.replace(/\s\w+$/, "");
797
+ const relativeId = this.getRelativeModuleId(m.identifier, context);
792
798
  const filesSet = /* @__PURE__ */ new Set();
793
799
  for (const file of chunk.files) {
794
800
  const index = fileToIndex(file);
@@ -807,11 +813,11 @@ class VueSSRClientPlugin {
807
813
  }
808
814
  }
809
815
  const files = Array.from(filesSet);
810
- webpackManifest.modules[hash(id)] = files;
816
+ webpackManifest.modules[relativeId] = files;
811
817
  if (Array.isArray(m.modules)) {
812
818
  for (const concatenatedModule of m.modules) {
813
- const id2 = hash(concatenatedModule.identifier.replace(/\s\w+$/, ""));
814
- webpackManifest.modules[id2] ||= files;
819
+ const relativeId2 = this.getRelativeModuleId(concatenatedModule.identifier, context);
820
+ webpackManifest.modules[relativeId2] ||= files;
815
821
  }
816
822
  }
817
823
  if (stats.modules) {
@@ -907,7 +913,7 @@ function vue(ctx) {
907
913
  ctx.config.module.rules.push({
908
914
  test: /\.vue$/i,
909
915
  loader: "vue-loader",
910
- options: ctx.userConfig.loaders.vue
916
+ options: { ...ctx.userConfig.loaders.vue, isServerBuild: ctx.isServer }
911
917
  });
912
918
  if (ctx.isClient) {
913
919
  ctx.config.plugins.push(new VueSSRClientPlugin({ nuxt: ctx.nuxt }));
@@ -915,6 +921,15 @@ function vue(ctx) {
915
921
  ctx.config.plugins.push(new VueSSRServerPlugin({
916
922
  filename: `${ctx.name}.manifest.json`
917
923
  }));
924
+ const loaderPath = resolveModulePath("#vue-module-identifier", { from: import.meta.url });
925
+ ctx.config.module.rules.push({
926
+ test: /\.vue$/i,
927
+ enforce: "post",
928
+ use: [{
929
+ loader: loaderPath,
930
+ options: { srcDir: ctx.nuxt.options.srcDir }
931
+ }]
932
+ });
918
933
  }
919
934
  ctx.config.plugins.push(new webpack.DefinePlugin({
920
935
  "__VUE_OPTIONS_API__": "true",
@@ -0,0 +1,8 @@
1
+ import { LoaderDefinitionFunction } from 'webpack';
2
+
3
+ interface LoaderOptions {
4
+ srcDir?: string;
5
+ }
6
+ declare const vueModuleIdentifierLoader: LoaderDefinitionFunction<LoaderOptions>;
7
+
8
+ export { vueModuleIdentifierLoader as default };
@@ -0,0 +1,8 @@
1
+ import { LoaderDefinitionFunction } from 'webpack';
2
+
3
+ interface LoaderOptions {
4
+ srcDir?: string;
5
+ }
6
+ declare const vueModuleIdentifierLoader: LoaderDefinitionFunction<LoaderOptions>;
7
+
8
+ export { vueModuleIdentifierLoader as default };
@@ -0,0 +1,18 @@
1
+ import { relative, normalize } from 'pathe';
2
+
3
+ const vueModuleIdentifierLoader = function(source) {
4
+ this.cacheable?.();
5
+ const { srcDir } = this.getOptions() || {};
6
+ const resourcePath = this.resourcePath || this._module?.resource;
7
+ if (!resourcePath || !source.includes("__exports__")) {
8
+ return source;
9
+ }
10
+ const context = srcDir || this.rootContext || this.context || this._compiler?.options?.context;
11
+ const relativePath = context ? relative(context, resourcePath) : resourcePath;
12
+ const moduleId = normalize(relativePath).replace(/^\.\//, "").replace(/\\/g, "/");
13
+ const snippet = `
14
+ ;__exports__.__moduleIdentifier = ${JSON.stringify(moduleId)};`;
15
+ return source + snippet;
16
+ };
17
+
18
+ export { vueModuleIdentifierLoader as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/webpack-builder-nightly",
3
- "version": "4.3.0-29443617.eabd3fee",
3
+ "version": "4.3.0-29444675.2f04ec3a",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/nuxt/nuxt.git",
@@ -12,7 +12,8 @@
12
12
  "type": "module",
13
13
  "types": "./dist/index.d.ts",
14
14
  "imports": {
15
- "#builder": "./builder.mjs"
15
+ "#builder": "./builder.mjs",
16
+ "#vue-module-identifier": "./dist/loaders/vue-module-identifier.mjs"
16
17
  },
17
18
  "exports": {
18
19
  ".": {
@@ -27,7 +28,7 @@
27
28
  ],
28
29
  "dependencies": {
29
30
  "@nuxt/friendly-errors-webpack-plugin": "^2.6.0",
30
- "@nuxt/kit": "npm:@nuxt/kit-nightly@4.3.0-29443617.eabd3fee",
31
+ "@nuxt/kit": "npm:@nuxt/kit-nightly@4.3.0-29444675.2f04ec3a",
31
32
  "autoprefixer": "^10.4.23",
32
33
  "css-loader": "^7.1.2",
33
34
  "css-minimizer-webpack-plugin": "^7.0.4",
@@ -71,7 +72,7 @@
71
72
  "webpackbar": "^7.0.0"
72
73
  },
73
74
  "devDependencies": {
74
- "@nuxt/schema": "npm:@nuxt/schema-nightly@4.3.0-29443617.eabd3fee",
75
+ "@nuxt/schema": "npm:@nuxt/schema-nightly@4.3.0-29444675.2f04ec3a",
75
76
  "@rspack/core": "1.6.8",
76
77
  "@types/webpack-bundle-analyzer": "4.7.0",
77
78
  "@types/webpack-hot-middleware": "2.25.12",
@@ -80,7 +81,7 @@
80
81
  "vue": "3.5.26"
81
82
  },
82
83
  "peerDependencies": {
83
- "nuxt": "npm:nuxt-nightly@4.3.0-29443617.eabd3fee",
84
+ "nuxt": "npm:nuxt-nightly@4.3.0-29444675.2f04ec3a",
84
85
  "vue": "^3.3.4"
85
86
  },
86
87
  "engines": {