@rsbuild/plugin-vue2 0.7.9 → 1.0.0-alpha.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.
@@ -0,0 +1,8 @@
1
+ import type { Rspack } from '@rsbuild/core';
2
+ /**
3
+ * this plugin is a quick fix for issue https://github.com/web-infra-dev/rsbuild/issues/2093
4
+ */
5
+ export declare class VueLoader15PitchFixPlugin implements Rspack.RspackPluginInstance {
6
+ readonly name = "VueLoader15PitchFixPlugin";
7
+ apply(compiler: Rspack.Compiler): void;
8
+ }
package/dist/index.cjs CHANGED
@@ -82,17 +82,18 @@ var VueLoader15PitchFixPlugin = class {
82
82
 
83
83
  // src/splitChunks.ts
84
84
  var import_shared = require("@rsbuild/shared");
85
+ var isPlainObject = (obj) => obj !== null && typeof obj === "object" && Object.prototype.toString.call(obj) === "[object Object]";
85
86
  var applySplitChunksRule = (api, options = {
86
87
  vue: true,
87
88
  router: true
88
89
  }) => {
89
- api.modifyBundlerChain((chain) => {
90
- const config = api.getNormalizedConfig();
90
+ api.modifyBundlerChain((chain, { environment }) => {
91
+ const { config } = environment;
91
92
  if (config.performance.chunkSplit.strategy !== "split-by-experience") {
92
93
  return;
93
94
  }
94
95
  const currentConfig = chain.optimization.splitChunks.values();
95
- if (!(0, import_shared.isPlainObject)(currentConfig)) {
96
+ if (!isPlainObject(currentConfig)) {
96
97
  return;
97
98
  }
98
99
  const extraGroups = {};
@@ -151,7 +152,11 @@ function pluginVue2(options = {}) {
151
152
  ...userLoaderOptions,
152
153
  compilerOptions
153
154
  };
154
- chain.module.rule(CHAIN_ID.RULE.VUE).test(VUE_REGEXP).use(CHAIN_ID.USE.VUE).loader(require.resolve("vue-loader")).options(vueLoaderOptions);
155
+ const rule = chain.module.rule(CHAIN_ID.RULE.VUE);
156
+ rule.test(VUE_REGEXP).use(CHAIN_ID.USE.VUE).loader(require.resolve("vue-loader")).options(vueLoaderOptions);
157
+ if (chain.module.rules.has(CHAIN_ID.RULE.JS)) {
158
+ applyResolveConfig(rule, chain.module.rule(CHAIN_ID.RULE.JS));
159
+ }
155
160
  chain.module.rule(CHAIN_ID.RULE.CSS).test(/\.(?:css|postcss|pcss)$/);
156
161
  chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_PLUGIN).use(import_vue_loader.VueLoaderPlugin);
157
162
  chain.plugin("vue-loader-15-pitch-fix").use(VueLoader15PitchFixPlugin);
@@ -160,6 +165,16 @@ function pluginVue2(options = {}) {
160
165
  }
161
166
  };
162
167
  }
168
+ function applyResolveConfig(vueRule, jsRule) {
169
+ const fullySpecified = jsRule.resolve.get("fullySpecified");
170
+ const aliases = jsRule.resolve.alias.entries();
171
+ if (aliases) {
172
+ vueRule.resolve.alias.merge(aliases);
173
+ }
174
+ if (fullySpecified !== void 0) {
175
+ vueRule.resolve.fullySpecified(fullySpecified);
176
+ }
177
+ }
163
178
  // Annotate the CommonJS export names for ESM import in node:
164
179
  0 && (module.exports = {
165
180
  PLUGIN_VUE2_NAME,
package/dist/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
- import { RsbuildPlugin } from '@rsbuild/core';
2
- import { VueLoaderOptions } from 'vue-loader';
3
-
4
- type SplitVueChunkOptions = {
1
+ import type { RsbuildPlugin } from '@rsbuild/core';
2
+ import { type VueLoaderOptions } from 'vue-loader';
3
+ export type SplitVueChunkOptions = {
5
4
  /**
6
5
  * Whether to enable split chunking for Vue-related dependencies (e.g., vue, vue-loader).
7
6
  * @default true
@@ -13,7 +12,7 @@ type SplitVueChunkOptions = {
13
12
  */
14
13
  router?: boolean;
15
14
  };
16
- type PluginVueOptions = {
15
+ export type PluginVueOptions = {
17
16
  /**
18
17
  * Options passed to `vue-loader`.
19
18
  * @see https://vue-loader.vuejs.org/
@@ -24,7 +23,5 @@ type PluginVueOptions = {
24
23
  */
25
24
  splitChunks?: SplitVueChunkOptions;
26
25
  };
27
- declare const PLUGIN_VUE2_NAME = "rsbuild:vue2";
28
- declare function pluginVue2(options?: PluginVueOptions): RsbuildPlugin;
29
-
30
- export { PLUGIN_VUE2_NAME, type PluginVueOptions, type SplitVueChunkOptions, pluginVue2 };
26
+ export declare const PLUGIN_VUE2_NAME = "rsbuild:vue2";
27
+ export declare function pluginVue2(options?: PluginVueOptions): RsbuildPlugin;
package/dist/index.js CHANGED
@@ -15,7 +15,7 @@ var __publicField = (obj, key, value) => {
15
15
  return value;
16
16
  };
17
17
 
18
- // ../../node_modules/.pnpm/@modern-js+module-tools@2.52.0_eslint@9.5.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js
18
+ // ../../node_modules/.pnpm/@modern-js+module-tools@2.54.5_eslint@9.6.0_typescript@5.5.2/node_modules/@modern-js/module-tools/shims/esm.js
19
19
  import { fileURLToPath } from "url";
20
20
  import path from "path";
21
21
 
@@ -62,13 +62,14 @@ var VueLoader15PitchFixPlugin = class {
62
62
  };
63
63
 
64
64
  // src/splitChunks.ts
65
- import { createCacheGroups, isPlainObject } from "@rsbuild/shared";
65
+ import { createCacheGroups } from "@rsbuild/shared";
66
+ var isPlainObject = (obj) => obj !== null && typeof obj === "object" && Object.prototype.toString.call(obj) === "[object Object]";
66
67
  var applySplitChunksRule = (api, options = {
67
68
  vue: true,
68
69
  router: true
69
70
  }) => {
70
- api.modifyBundlerChain((chain) => {
71
- const config = api.getNormalizedConfig();
71
+ api.modifyBundlerChain((chain, { environment }) => {
72
+ const { config } = environment;
72
73
  if (config.performance.chunkSplit.strategy !== "split-by-experience") {
73
74
  return;
74
75
  }
@@ -132,7 +133,11 @@ function pluginVue2(options = {}) {
132
133
  ...userLoaderOptions,
133
134
  compilerOptions
134
135
  };
135
- chain.module.rule(CHAIN_ID.RULE.VUE).test(VUE_REGEXP).use(CHAIN_ID.USE.VUE).loader(__require.resolve("vue-loader")).options(vueLoaderOptions);
136
+ const rule = chain.module.rule(CHAIN_ID.RULE.VUE);
137
+ rule.test(VUE_REGEXP).use(CHAIN_ID.USE.VUE).loader(__require.resolve("vue-loader")).options(vueLoaderOptions);
138
+ if (chain.module.rules.has(CHAIN_ID.RULE.JS)) {
139
+ applyResolveConfig(rule, chain.module.rule(CHAIN_ID.RULE.JS));
140
+ }
136
141
  chain.module.rule(CHAIN_ID.RULE.CSS).test(/\.(?:css|postcss|pcss)$/);
137
142
  chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_PLUGIN).use(VueLoaderPlugin);
138
143
  chain.plugin("vue-loader-15-pitch-fix").use(VueLoader15PitchFixPlugin);
@@ -141,6 +146,16 @@ function pluginVue2(options = {}) {
141
146
  }
142
147
  };
143
148
  }
149
+ function applyResolveConfig(vueRule, jsRule) {
150
+ const fullySpecified = jsRule.resolve.get("fullySpecified");
151
+ const aliases = jsRule.resolve.alias.entries();
152
+ if (aliases) {
153
+ vueRule.resolve.alias.merge(aliases);
154
+ }
155
+ if (fullySpecified !== void 0) {
156
+ vueRule.resolve.fullySpecified(fullySpecified);
157
+ }
158
+ }
144
159
  export {
145
160
  PLUGIN_VUE2_NAME,
146
161
  pluginVue2
@@ -0,0 +1,3 @@
1
+ import type { RsbuildPluginAPI } from '@rsbuild/core';
2
+ import type { SplitVueChunkOptions } from '.';
3
+ export declare const applySplitChunksRule: (api: RsbuildPluginAPI, options?: SplitVueChunkOptions) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-vue2",
3
- "version": "0.7.9",
3
+ "version": "1.0.0-alpha.0",
4
4
  "description": "Vue 2 plugin of Rsbuild",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "repository": {
@@ -24,17 +24,17 @@
24
24
  ],
25
25
  "dependencies": {
26
26
  "vue-loader": "^15.11.1",
27
- "webpack": "^5.92.0",
28
- "@rsbuild/shared": "0.7.9"
27
+ "webpack": "^5.92.1",
28
+ "@rsbuild/shared": "1.0.0-alpha.0"
29
29
  },
30
30
  "devDependencies": {
31
- "typescript": "^5.4.2",
32
- "webpack": "^5.92.0",
33
- "@rsbuild/core": "0.7.9",
34
- "@scripts/test-helper": "0.7.9"
31
+ "typescript": "^5.5.2",
32
+ "webpack": "^5.92.1",
33
+ "@rsbuild/core": "1.0.0-alpha.0",
34
+ "@scripts/test-helper": "1.0.0-alpha.0"
35
35
  },
36
36
  "peerDependencies": {
37
- "@rsbuild/core": "^0.7.9"
37
+ "@rsbuild/core": "^1.0.0-alpha.0"
38
38
  },
39
39
  "publishConfig": {
40
40
  "access": "public",