@rsbuild/plugin-vue2 0.6.4 → 0.6.6

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.js CHANGED
@@ -5,6 +5,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
9
  var __export = (target, all) => {
9
10
  for (var name in all)
10
11
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -26,6 +27,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
27
  mod
27
28
  ));
28
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+ var __publicField = (obj, key, value) => {
31
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
32
+ return value;
33
+ };
29
34
 
30
35
  // src/index.ts
31
36
  var src_exports = {};
@@ -36,6 +41,45 @@ module.exports = __toCommonJS(src_exports);
36
41
  var import_shared2 = require("@rsbuild/shared");
37
42
  var import_vue_loader = require("vue-loader");
38
43
 
44
+ // src/VueLoader15PitchFixPlugin.ts
45
+ var VueLoader15PitchFixPlugin = class {
46
+ constructor() {
47
+ __publicField(this, "name", "VueLoader15PitchFixPlugin");
48
+ }
49
+ apply(compiler) {
50
+ const { NormalModule } = compiler.webpack;
51
+ compiler.hooks.compilation.tap(this.name, (compilation) => {
52
+ const isExpCssOn = compilation.compiler.options?.experiments?.css;
53
+ if (!isExpCssOn)
54
+ return;
55
+ NormalModule.getCompilationHooks(compilation).loader.tap(
56
+ this.name,
57
+ (loaderContext) => {
58
+ if (
59
+ // the related issue only happens for <style>
60
+ /[?&]type=style/.test(loaderContext.resourceQuery) && // the fix should be applied before `pitch` phase completed.
61
+ // once `pitch` phase completed, vue-loader will remove its pitcher loader.
62
+ /[\\/]vue-loader[\\/]lib[\\/]loaders[\\/]pitcher/.test(
63
+ loaderContext.loaders?.[0]?.path || ""
64
+ )
65
+ ) {
66
+ const seen = /* @__PURE__ */ new Set();
67
+ const loaders = [];
68
+ for (const loader of loaderContext.loaders || []) {
69
+ const identifier = typeof loader === "string" ? loader : loader.path + loader.query;
70
+ if (!seen.has(identifier)) {
71
+ seen.add(identifier);
72
+ loaders.push(loader);
73
+ }
74
+ }
75
+ loaderContext.loaders = loaders;
76
+ }
77
+ }
78
+ );
79
+ });
80
+ }
81
+ };
82
+
39
83
  // src/splitChunks.ts
40
84
  var import_shared = require("@rsbuild/shared");
41
85
  var applySplitChunksRule = (api, options = {
@@ -93,6 +137,7 @@ function pluginVue2(options = {}) {
93
137
  );
94
138
  chain.module.rule(CHAIN_ID.RULE.VUE).test(/\.vue$/).use(CHAIN_ID.USE.VUE).loader(require.resolve("vue-loader")).options(vueLoaderOptions);
95
139
  chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_PLUGIN).use(import_vue_loader.VueLoaderPlugin);
140
+ chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_15_PITCH_FIX_PLUGIN).use(VueLoader15PitchFixPlugin);
96
141
  });
97
142
  applySplitChunksRule(api, options.splitChunks);
98
143
  }
package/dist/index.mjs CHANGED
@@ -1,6 +1,8 @@
1
1
  import { createRequire } from 'module';
2
2
  var require = createRequire(import.meta['url']);
3
3
 
4
+ var __defProp = Object.defineProperty;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
6
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
5
7
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
6
8
  }) : x)(function(x) {
@@ -8,6 +10,10 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
8
10
  return require.apply(this, arguments);
9
11
  throw Error('Dynamic require of "' + x + '" is not supported');
10
12
  });
13
+ var __publicField = (obj, key, value) => {
14
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
15
+ return value;
16
+ };
11
17
 
12
18
  // ../../node_modules/.pnpm/@modern-js+module-tools@2.49.0_eslint@8.57.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js
13
19
  import { fileURLToPath } from "url";
@@ -17,10 +23,49 @@ import path from "path";
17
23
  import { deepmerge } from "@rsbuild/shared";
18
24
  import { VueLoaderPlugin } from "vue-loader";
19
25
 
26
+ // src/VueLoader15PitchFixPlugin.ts
27
+ var VueLoader15PitchFixPlugin = class {
28
+ constructor() {
29
+ __publicField(this, "name", "VueLoader15PitchFixPlugin");
30
+ }
31
+ apply(compiler) {
32
+ const { NormalModule } = compiler.webpack;
33
+ compiler.hooks.compilation.tap(this.name, (compilation) => {
34
+ const isExpCssOn = compilation.compiler.options?.experiments?.css;
35
+ if (!isExpCssOn)
36
+ return;
37
+ NormalModule.getCompilationHooks(compilation).loader.tap(
38
+ this.name,
39
+ (loaderContext) => {
40
+ if (
41
+ // the related issue only happens for <style>
42
+ /[?&]type=style/.test(loaderContext.resourceQuery) && // the fix should be applied before `pitch` phase completed.
43
+ // once `pitch` phase completed, vue-loader will remove its pitcher loader.
44
+ /[\\/]vue-loader[\\/]lib[\\/]loaders[\\/]pitcher/.test(
45
+ loaderContext.loaders?.[0]?.path || ""
46
+ )
47
+ ) {
48
+ const seen = /* @__PURE__ */ new Set();
49
+ const loaders = [];
50
+ for (const loader of loaderContext.loaders || []) {
51
+ const identifier = typeof loader === "string" ? loader : loader.path + loader.query;
52
+ if (!seen.has(identifier)) {
53
+ seen.add(identifier);
54
+ loaders.push(loader);
55
+ }
56
+ }
57
+ loaderContext.loaders = loaders;
58
+ }
59
+ }
60
+ );
61
+ });
62
+ }
63
+ };
64
+
20
65
  // src/splitChunks.ts
21
66
  import {
22
- isPlainObject,
23
- createCacheGroups
67
+ createCacheGroups,
68
+ isPlainObject
24
69
  } from "@rsbuild/shared";
25
70
  var applySplitChunksRule = (api, options = {
26
71
  vue: true,
@@ -77,6 +122,7 @@ function pluginVue2(options = {}) {
77
122
  );
78
123
  chain.module.rule(CHAIN_ID.RULE.VUE).test(/\.vue$/).use(CHAIN_ID.USE.VUE).loader(__require.resolve("vue-loader")).options(vueLoaderOptions);
79
124
  chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_PLUGIN).use(VueLoaderPlugin);
125
+ chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_15_PITCH_FIX_PLUGIN).use(VueLoader15PitchFixPlugin);
80
126
  });
81
127
  applySplitChunksRule(api, options.splitChunks);
82
128
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-vue2",
3
- "version": "0.6.4",
3
+ "version": "0.6.6",
4
4
  "description": "Vue 2 plugin of Rsbuild",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "repository": {
@@ -25,16 +25,16 @@
25
25
  "dependencies": {
26
26
  "vue-loader": "^15.11.1",
27
27
  "webpack": "^5.91.0",
28
- "@rsbuild/shared": "0.6.4"
28
+ "@rsbuild/shared": "0.6.6"
29
29
  },
30
30
  "devDependencies": {
31
31
  "typescript": "^5.4.2",
32
32
  "webpack": "^5.91.0",
33
- "@scripts/test-helper": "0.6.4",
34
- "@rsbuild/core": "0.6.4"
33
+ "@rsbuild/core": "0.6.6",
34
+ "@scripts/test-helper": "0.6.6"
35
35
  },
36
36
  "peerDependencies": {
37
- "@rsbuild/core": "^0.6.4"
37
+ "@rsbuild/core": "^0.6.6"
38
38
  },
39
39
  "publishConfig": {
40
40
  "access": "public",