@rsbuild/plugin-vue 1.0.3 → 1.0.5

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
@@ -1,126 +1,87 @@
1
1
  "use strict";
2
- // The require scope
3
2
  var __webpack_require__ = {};
4
- /************************************************************************/ // webpack/runtime/define_property_getters
5
- (()=>{
6
- __webpack_require__.d = function(exports1, definition) {
7
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
8
- enumerable: true,
9
- get: definition[key]
10
- });
11
- };
12
- })();
13
- // webpack/runtime/has_own_property
14
- (()=>{
15
- __webpack_require__.o = function(obj, prop) {
16
- return Object.prototype.hasOwnProperty.call(obj, prop);
17
- };
18
- })();
19
- // webpack/runtime/make_namespace_object
20
- (()=>{
21
- // define __esModule on exports
22
- __webpack_require__.r = function(exports1) {
23
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
24
- value: 'Module'
25
- });
26
- Object.defineProperty(exports1, '__esModule', {
27
- value: true
28
- });
29
- };
30
- })();
31
- /************************************************************************/ var __webpack_exports__ = {};
32
- // ESM COMPAT FLAG
33
- __webpack_require__.r(__webpack_exports__);
34
- // EXPORTS
35
- __webpack_require__.d(__webpack_exports__, {
36
- pluginVue: ()=>/* binding */ pluginVue,
37
- PLUGIN_VUE_NAME: ()=>/* binding */ PLUGIN_VUE_NAME
3
+ __webpack_require__.d = function(exports1, definition) {
4
+ for(var key in definition)__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key) && Object.defineProperty(exports1, key, {
5
+ enumerable: !0,
6
+ get: definition[key]
7
+ });
8
+ }, __webpack_require__.o = function(obj, prop) {
9
+ return Object.prototype.hasOwnProperty.call(obj, prop);
10
+ }, __webpack_require__.r = function(exports1) {
11
+ 'undefined' != typeof Symbol && Symbol.toStringTag && Object.defineProperty(exports1, Symbol.toStringTag, {
12
+ value: 'Module'
13
+ }), Object.defineProperty(exports1, '__esModule', {
14
+ value: !0
15
+ });
16
+ };
17
+ var __webpack_exports__ = {};
18
+ __webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_exports__, {
19
+ pluginVue: ()=>pluginVue,
20
+ PLUGIN_VUE_NAME: ()=>PLUGIN_VUE_NAME
38
21
  });
39
- const external_node_module_namespaceObject = require("node:module");
40
- const external_vue_loader_namespaceObject = require("vue-loader");
41
- const isPlainObject = (obj)=>null !== obj && 'object' == typeof obj && '[object Object]' === Object.prototype.toString.call(obj);
42
- const applySplitChunksRule = (api, options = {
43
- vue: true,
44
- router: true
22
+ let external_node_module_namespaceObject = require("node:module"), external_vue_loader_namespaceObject = require("vue-loader"), isPlainObject = (obj)=>null !== obj && 'object' == typeof obj && '[object Object]' === Object.prototype.toString.call(obj), applySplitChunksRule = (api, options = {
23
+ vue: !0,
24
+ router: !0
45
25
  })=>{
46
26
  api.modifyBundlerChain((chain, { environment })=>{
47
- const { config } = environment;
27
+ let { config } = environment;
48
28
  if ('split-by-experience' !== config.performance.chunkSplit.strategy) return;
49
- const currentConfig = chain.optimization.splitChunks.values();
29
+ let currentConfig = chain.optimization.splitChunks.values();
50
30
  if (!isPlainObject(currentConfig)) return;
51
- const extraGroups = {};
52
- if (options.vue) extraGroups.vue = {
31
+ let extraGroups = {};
32
+ if (options.vue && (extraGroups.vue = {
53
33
  name: 'lib-vue',
54
34
  test: /node_modules[\\/](?:vue|vue-loader|@vue[\\/]shared|@vue[\\/]reactivity|@vue[\\/]runtime-dom|@vue[\\/]runtime-core)[\\/]/,
55
35
  priority: 0
56
- };
57
- if (options.router) extraGroups.router = {
36
+ }), options.router && (extraGroups.router = {
58
37
  name: 'lib-router',
59
38
  test: /node_modules[\\/]vue-router[\\/]/,
60
39
  priority: 0
61
- };
62
- if (!Object.keys(extraGroups).length) return;
63
- chain.optimization.splitChunks({
40
+ }), !!Object.keys(extraGroups).length) chain.optimization.splitChunks({
64
41
  ...currentConfig,
65
42
  cacheGroups: {
66
- ...currentConfig.cacheGroups,
67
- ...extraGroups
43
+ ...extraGroups,
44
+ ...currentConfig.cacheGroups
68
45
  }
69
46
  });
70
47
  });
71
- };
72
- const src_require = (0, external_node_module_namespaceObject.createRequire)(/*#__PURE__*/ function() {
73
- return 'undefined' == typeof document ? new (module.require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
74
- }());
75
- const PLUGIN_VUE_NAME = 'rsbuild:vue';
48
+ }, src_require = (0, external_node_module_namespaceObject.createRequire)('undefined' == typeof document ? new (module.require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href), PLUGIN_VUE_NAME = 'rsbuild:vue';
76
49
  function pluginVue(options = {}) {
77
50
  return {
78
51
  name: PLUGIN_VUE_NAME,
79
52
  setup (api) {
80
- const VUE_REGEXP = /\.vue$/;
81
- const CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
53
+ let VUE_REGEXP = /\.vue$/, CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
82
54
  api.modifyEnvironmentConfig((config, { mergeEnvironmentConfig })=>{
83
- const extraConfig = {
55
+ let merged = mergeEnvironmentConfig({
84
56
  source: {
85
57
  define: {
86
- // https://link.vuejs.org/feature-flags
87
- __VUE_OPTIONS_API__: true,
88
- __VUE_PROD_DEVTOOLS__: false,
89
- __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false
90
- }
58
+ __VUE_OPTIONS_API__: !0,
59
+ __VUE_PROD_DEVTOOLS__: !1,
60
+ __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: !1
61
+ },
62
+ include: [
63
+ /\.vue.js$/
64
+ ]
91
65
  }
92
- };
93
- const merged = mergeEnvironmentConfig(extraConfig, config);
94
- // Support `<style module>` in Vue SFC
95
- if (true === merged.output.cssModules.auto) merged.output.cssModules.auto = (path, query)=>{
96
- if (VUE_REGEXP.test(path)) return query.includes('type=style') && query.includes('module=true');
97
- return CSS_MODULES_REGEX.test(path);
98
- };
99
- return merged;
100
- });
101
- api.modifyBundlerChain(async (chain, { CHAIN_ID })=>{
66
+ }, config);
67
+ return !0 === merged.output.cssModules.auto && (merged.output.cssModules.auto = (path, query)=>VUE_REGEXP.test(path) ? query.includes('type=style') && query.includes('module=true') : CSS_MODULES_REGEX.test(path)), merged;
68
+ }), api.modifyBundlerChain(async (chain, { CHAIN_ID })=>{
102
69
  chain.resolve.extensions.add('.vue');
103
- const userLoaderOptions = options.vueLoaderOptions ?? {};
104
- const compilerOptions = {
105
- preserveWhitespace: false,
70
+ let userLoaderOptions = options.vueLoaderOptions ?? {}, compilerOptions = {
71
+ preserveWhitespace: !1,
106
72
  ...userLoaderOptions.compilerOptions
107
- };
108
- const vueLoaderOptions = {
109
- experimentalInlineMatchResource: true,
73
+ }, vueLoaderOptions = {
74
+ experimentalInlineMatchResource: !0,
110
75
  ...userLoaderOptions,
111
76
  compilerOptions
112
77
  };
113
- chain.module.rule(CHAIN_ID.RULE.VUE).test(VUE_REGEXP).use(CHAIN_ID.USE.VUE).loader(src_require.resolve('vue-loader')).options(vueLoaderOptions);
114
- // Support for lang="postcss" and lang="pcss" in SFC
115
- chain.module.rule(CHAIN_ID.RULE.CSS).test(/\.(?:css|postcss|pcss)$/);
116
- chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_PLUGIN).use(external_vue_loader_namespaceObject.VueLoaderPlugin);
117
- });
118
- applySplitChunksRule(api, options.splitChunks);
78
+ chain.module.rule(CHAIN_ID.RULE.VUE).test(VUE_REGEXP).use(CHAIN_ID.USE.VUE).loader(src_require.resolve('vue-loader')).options(vueLoaderOptions), chain.module.rule(CHAIN_ID.RULE.CSS).test(/\.(?:css|postcss|pcss)$/), chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_PLUGIN).use(external_vue_loader_namespaceObject.VueLoaderPlugin);
79
+ }), applySplitChunksRule(api, options.splitChunks);
119
80
  }
120
81
  };
121
82
  }
122
83
  var __webpack_export_target__ = exports;
123
84
  for(var i in __webpack_exports__)__webpack_export_target__[i] = __webpack_exports__[i];
124
- if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
125
- value: true
85
+ __webpack_exports__.__esModule && Object.defineProperty(__webpack_export_target__, '__esModule', {
86
+ value: !0
126
87
  });
package/dist/index.js CHANGED
@@ -1,81 +1,63 @@
1
1
  import * as __WEBPACK_EXTERNAL_MODULE_node_module__ from "node:module";
2
2
  import * as __WEBPACK_EXTERNAL_MODULE_vue_loader__ from "vue-loader";
3
- const isPlainObject = (obj)=>null !== obj && 'object' == typeof obj && '[object Object]' === Object.prototype.toString.call(obj);
4
- const applySplitChunksRule = (api, options = {
5
- vue: true,
6
- router: true
3
+ let isPlainObject = (obj)=>null !== obj && 'object' == typeof obj && '[object Object]' === Object.prototype.toString.call(obj), applySplitChunksRule = (api, options = {
4
+ vue: !0,
5
+ router: !0
7
6
  })=>{
8
7
  api.modifyBundlerChain((chain, { environment })=>{
9
- const { config } = environment;
8
+ let { config } = environment;
10
9
  if ('split-by-experience' !== config.performance.chunkSplit.strategy) return;
11
- const currentConfig = chain.optimization.splitChunks.values();
10
+ let currentConfig = chain.optimization.splitChunks.values();
12
11
  if (!isPlainObject(currentConfig)) return;
13
- const extraGroups = {};
14
- if (options.vue) extraGroups.vue = {
12
+ let extraGroups = {};
13
+ if (options.vue && (extraGroups.vue = {
15
14
  name: 'lib-vue',
16
15
  test: /node_modules[\\/](?:vue|vue-loader|@vue[\\/]shared|@vue[\\/]reactivity|@vue[\\/]runtime-dom|@vue[\\/]runtime-core)[\\/]/,
17
16
  priority: 0
18
- };
19
- if (options.router) extraGroups.router = {
17
+ }), options.router && (extraGroups.router = {
20
18
  name: 'lib-router',
21
19
  test: /node_modules[\\/]vue-router[\\/]/,
22
20
  priority: 0
23
- };
24
- if (!Object.keys(extraGroups).length) return;
25
- chain.optimization.splitChunks({
21
+ }), !!Object.keys(extraGroups).length) chain.optimization.splitChunks({
26
22
  ...currentConfig,
27
23
  cacheGroups: {
28
- ...currentConfig.cacheGroups,
29
- ...extraGroups
24
+ ...extraGroups,
25
+ ...currentConfig.cacheGroups
30
26
  }
31
27
  });
32
28
  });
33
- };
34
- const src_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module__.createRequire)(import.meta.url);
35
- const PLUGIN_VUE_NAME = 'rsbuild:vue';
29
+ }, src_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module__.createRequire)(import.meta.url), PLUGIN_VUE_NAME = 'rsbuild:vue';
36
30
  function pluginVue(options = {}) {
37
31
  return {
38
32
  name: PLUGIN_VUE_NAME,
39
33
  setup (api) {
40
- const VUE_REGEXP = /\.vue$/;
41
- const CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
34
+ let VUE_REGEXP = /\.vue$/, CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
42
35
  api.modifyEnvironmentConfig((config, { mergeEnvironmentConfig })=>{
43
- const extraConfig = {
36
+ let merged = mergeEnvironmentConfig({
44
37
  source: {
45
38
  define: {
46
- // https://link.vuejs.org/feature-flags
47
- __VUE_OPTIONS_API__: true,
48
- __VUE_PROD_DEVTOOLS__: false,
49
- __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false
50
- }
39
+ __VUE_OPTIONS_API__: !0,
40
+ __VUE_PROD_DEVTOOLS__: !1,
41
+ __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: !1
42
+ },
43
+ include: [
44
+ /\.vue.js$/
45
+ ]
51
46
  }
52
- };
53
- const merged = mergeEnvironmentConfig(extraConfig, config);
54
- // Support `<style module>` in Vue SFC
55
- if (true === merged.output.cssModules.auto) merged.output.cssModules.auto = (path, query)=>{
56
- if (VUE_REGEXP.test(path)) return query.includes('type=style') && query.includes('module=true');
57
- return CSS_MODULES_REGEX.test(path);
58
- };
59
- return merged;
60
- });
61
- api.modifyBundlerChain(async (chain, { CHAIN_ID })=>{
47
+ }, config);
48
+ return !0 === merged.output.cssModules.auto && (merged.output.cssModules.auto = (path, query)=>VUE_REGEXP.test(path) ? query.includes('type=style') && query.includes('module=true') : CSS_MODULES_REGEX.test(path)), merged;
49
+ }), api.modifyBundlerChain(async (chain, { CHAIN_ID })=>{
62
50
  chain.resolve.extensions.add('.vue');
63
- const userLoaderOptions = options.vueLoaderOptions ?? {};
64
- const compilerOptions = {
65
- preserveWhitespace: false,
51
+ let userLoaderOptions = options.vueLoaderOptions ?? {}, compilerOptions = {
52
+ preserveWhitespace: !1,
66
53
  ...userLoaderOptions.compilerOptions
67
- };
68
- const vueLoaderOptions = {
69
- experimentalInlineMatchResource: true,
54
+ }, vueLoaderOptions = {
55
+ experimentalInlineMatchResource: !0,
70
56
  ...userLoaderOptions,
71
57
  compilerOptions
72
58
  };
73
- chain.module.rule(CHAIN_ID.RULE.VUE).test(VUE_REGEXP).use(CHAIN_ID.USE.VUE).loader(src_require.resolve('vue-loader')).options(vueLoaderOptions);
74
- // Support for lang="postcss" and lang="pcss" in SFC
75
- chain.module.rule(CHAIN_ID.RULE.CSS).test(/\.(?:css|postcss|pcss)$/);
76
- chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_PLUGIN).use(__WEBPACK_EXTERNAL_MODULE_vue_loader__.VueLoaderPlugin);
77
- });
78
- applySplitChunksRule(api, options.splitChunks);
59
+ chain.module.rule(CHAIN_ID.RULE.VUE).test(VUE_REGEXP).use(CHAIN_ID.USE.VUE).loader(src_require.resolve('vue-loader')).options(vueLoaderOptions), chain.module.rule(CHAIN_ID.RULE.CSS).test(/\.(?:css|postcss|pcss)$/), chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_PLUGIN).use(__WEBPACK_EXTERNAL_MODULE_vue_loader__.VueLoaderPlugin);
60
+ }), applySplitChunksRule(api, options.splitChunks);
79
61
  }
80
62
  };
81
63
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-vue",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Vue 3 plugin of Rsbuild",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "repository": {
@@ -24,13 +24,15 @@
24
24
  ],
25
25
  "dependencies": {
26
26
  "vue-loader": "^17.4.2",
27
- "webpack": "^5.95.0"
27
+ "webpack": "^5.96.1"
28
28
  },
29
29
  "devDependencies": {
30
+ "@rslib/core": "0.0.18",
31
+ "@types/node": "^22.9.0",
30
32
  "typescript": "^5.6.3",
31
33
  "vue": "^3.5.12",
32
- "webpack": "^5.95.0",
33
- "@rsbuild/core": "1.0.19",
34
+ "webpack": "^5.96.1",
35
+ "@rsbuild/core": "1.1.2",
34
36
  "@scripts/test-helper": "1.0.1"
35
37
  },
36
38
  "peerDependencies": {