@rsbuild/plugin-vue 1.2.3 → 1.2.4

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.cjs CHANGED
@@ -18,13 +18,17 @@ __webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_expo
18
18
  PLUGIN_VUE_NAME: ()=>PLUGIN_VUE_NAME,
19
19
  pluginVue: ()=>pluginVue
20
20
  });
21
- const external_node_module_namespaceObject = require("node:module"), external_rspack_vue_loader_namespaceObject = require("rspack-vue-loader"), isPlainObject = (obj)=>null !== obj && 'object' == typeof obj && '[object Object]' === Object.prototype.toString.call(obj), applySplitChunksRule = (api, options = {
21
+ const external_node_module_namespaceObject = require("node:module"), external_rspack_vue_loader_namespaceObject = require("rspack-vue-loader"), isPlainObject = (obj)=>null !== obj && 'object' == typeof obj && '[object Object]' === Object.prototype.toString.call(obj), isDefaultPreset = (config)=>{
22
+ let { performance, splitChunks } = config;
23
+ return performance.chunkSplit && 'object' == typeof splitChunks && 0 === Object.keys(splitChunks).length ? performance.chunkSplit?.strategy === 'split-by-experience' : 'object' == typeof splitChunks && (!splitChunks.preset || 'default' === splitChunks.preset);
24
+ };
25
+ function applySplitChunksRule(api, options = {
22
26
  vue: !0,
23
27
  router: !0
24
- })=>{
28
+ }) {
25
29
  api.modifyBundlerChain((chain, { environment })=>{
26
30
  let { config } = environment;
27
- if ('split-by-experience' !== config.performance.chunkSplit.strategy) return;
31
+ if (!isDefaultPreset(config) || 'web' !== config.output.target) return;
28
32
  let currentConfig = chain.optimization.splitChunks.values();
29
33
  if (!isPlainObject(currentConfig)) return;
30
34
  let extraGroups = {};
@@ -44,7 +48,8 @@ const external_node_module_namespaceObject = require("node:module"), external_rs
44
48
  }
45
49
  });
46
50
  });
47
- }, src_require = (0, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__), PLUGIN_VUE_NAME = 'rsbuild:vue';
51
+ }
52
+ const src_require = (0, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__), PLUGIN_VUE_NAME = 'rsbuild:vue';
48
53
  function pluginVue(options = {}) {
49
54
  return {
50
55
  name: PLUGIN_VUE_NAME,
package/dist/index.js CHANGED
@@ -1,5 +1,35 @@
1
1
  import { createRequire } from "node:module";
2
2
  import { VueLoaderPlugin } from "rspack-vue-loader";
3
+ function applySplitChunksRule(api, options = {
4
+ vue: !0,
5
+ router: !0
6
+ }) {
7
+ api.modifyBundlerChain((chain, { environment })=>{
8
+ let { config } = environment;
9
+ if (!((config)=>{
10
+ let { performance, splitChunks } = config;
11
+ return performance.chunkSplit && 'object' == typeof splitChunks && 0 === Object.keys(splitChunks).length ? performance.chunkSplit?.strategy === 'split-by-experience' : 'object' == typeof splitChunks && (!splitChunks.preset || 'default' === splitChunks.preset);
12
+ })(config) || 'web' !== config.output.target) return;
13
+ let currentConfig = chain.optimization.splitChunks.values();
14
+ if (null === currentConfig || 'object' != typeof currentConfig || '[object Object]' !== Object.prototype.toString.call(currentConfig)) return;
15
+ let extraGroups = {};
16
+ options.vue && (extraGroups.vue = {
17
+ name: 'lib-vue',
18
+ test: /node_modules[\\/](?:vue|rspack-vue-loader|@vue[\\/]shared|@vue[\\/]reactivity|@vue[\\/]runtime-dom|@vue[\\/]runtime-core)[\\/]/,
19
+ priority: 0
20
+ }), options.router && (extraGroups.router = {
21
+ name: 'lib-router',
22
+ test: /node_modules[\\/]vue-router[\\/]/,
23
+ priority: 0
24
+ }), Object.keys(extraGroups).length && chain.optimization.splitChunks({
25
+ ...currentConfig,
26
+ cacheGroups: {
27
+ ...extraGroups,
28
+ ...currentConfig.cacheGroups
29
+ }
30
+ });
31
+ });
32
+ }
3
33
  let src_require = createRequire(import.meta.url), PLUGIN_VUE_NAME = 'rsbuild:vue';
4
34
  function pluginVue(options = {}) {
5
35
  return {
@@ -40,33 +70,7 @@ function pluginVue(options = {}) {
40
70
  compilerOptions
41
71
  };
42
72
  chain.module.rule(CHAIN_ID.RULE.VUE).test(test).use(CHAIN_ID.USE.VUE).loader(src_require.resolve('rspack-vue-loader')).options(vueLoaderOptions), chain.module.rule(CHAIN_ID.RULE.CSS).test(/\.(?:css|postcss|pcss)$/), chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_PLUGIN).before(CHAIN_ID.PLUGIN.REACT_FAST_REFRESH).use(VueLoaderPlugin);
43
- }), ((api, options = {
44
- vue: !0,
45
- router: !0
46
- })=>{
47
- api.modifyBundlerChain((chain, { environment })=>{
48
- let { config } = environment;
49
- if ('split-by-experience' !== config.performance.chunkSplit.strategy) return;
50
- let currentConfig = chain.optimization.splitChunks.values();
51
- if (null === currentConfig || 'object' != typeof currentConfig || '[object Object]' !== Object.prototype.toString.call(currentConfig)) return;
52
- let extraGroups = {};
53
- options.vue && (extraGroups.vue = {
54
- name: 'lib-vue',
55
- test: /node_modules[\\/](?:vue|rspack-vue-loader|@vue[\\/]shared|@vue[\\/]reactivity|@vue[\\/]runtime-dom|@vue[\\/]runtime-core)[\\/]/,
56
- priority: 0
57
- }), options.router && (extraGroups.router = {
58
- name: 'lib-router',
59
- test: /node_modules[\\/]vue-router[\\/]/,
60
- priority: 0
61
- }), Object.keys(extraGroups).length && chain.optimization.splitChunks({
62
- ...currentConfig,
63
- cacheGroups: {
64
- ...extraGroups,
65
- ...currentConfig.cacheGroups
66
- }
67
- });
68
- });
69
- })(api, options.splitChunks);
73
+ }), applySplitChunksRule(api, options.splitChunks);
70
74
  }
71
75
  };
72
76
  }
@@ -1,3 +1,3 @@
1
1
  import type { RsbuildPluginAPI } from '@rsbuild/core';
2
2
  import type { SplitVueChunkOptions } from './index.js';
3
- export declare const applySplitChunksRule: (api: RsbuildPluginAPI, options?: SplitVueChunkOptions) => void;
3
+ export declare function applySplitChunksRule(api: RsbuildPluginAPI, options?: SplitVueChunkOptions): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-vue",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "description": "Vue 3 plugin of Rsbuild",
5
5
  "homepage": "https://rsbuild.rs",
6
6
  "repository": {
@@ -23,16 +23,16 @@
23
23
  "dist"
24
24
  ],
25
25
  "dependencies": {
26
- "rspack-vue-loader": "^17.4.4",
26
+ "rspack-vue-loader": "^17.4.5",
27
27
  "webpack": "^5.104.1"
28
28
  },
29
29
  "devDependencies": {
30
- "@rslib/core": "0.19.1",
31
- "@types/node": "^24.10.4",
30
+ "@rslib/core": "0.19.3",
31
+ "@types/node": "^24.10.9",
32
32
  "typescript": "^5.9.3",
33
- "vue": "^3.5.26",
34
- "@scripts/test-helper": "1.0.1",
35
- "@rsbuild/core": "1.7.2"
33
+ "vue": "^3.5.27",
34
+ "@rsbuild/core": "2.0.0-beta.0",
35
+ "@scripts/test-helper": "1.0.1"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "@rsbuild/core": "^1.0.0 || ^2.0.0-0"