@rsbuild/plugin-vue 1.0.4 → 1.0.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/README.md CHANGED
@@ -1,19 +1,19 @@
1
- <p align="center">
2
- <a href="https://rsbuild.dev" target="blank"><img src="https://github.com/web-infra-dev/rsbuild/assets/7237365/84abc13e-b620-468f-a90b-dbf28e7e9427" alt="Rsbuild Logo" /></a>
3
- </p>
1
+ # @rsbuild/plugin-vue
4
2
 
5
- # Rsbuild
3
+ An Rsbuild plugin to provide support for Vue 3.
6
4
 
7
- The Rspack-based build tool. It's fast, out-of-the-box and extensible.
5
+ <p>
6
+ <a href="https://npmjs.com/package/@rsbuild/plugin-vue">
7
+ <img src="https://img.shields.io/npm/v/@rsbuild/plugin-vue?style=flat-square&colorA=564341&colorB=EDED91" alt="npm version" />
8
+ </a>
9
+ <img src="https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square&colorA=564341&colorB=EDED91" alt="license" />
10
+ <a href="https://npmcharts.com/compare/@rsbuild/plugin-vue?minimal=true"><img src="https://img.shields.io/npm/dm/@rsbuild/plugin-vue.svg?style=flat-square&colorA=564341&colorB=EDED91" alt="downloads" /></a>
11
+ </p>
8
12
 
9
13
  ## Documentation
10
14
 
11
- https://rsbuild.dev/
12
-
13
- ## Contributing
14
-
15
- Please read the [Contributing Guide](https://github.com/web-infra-dev/rsbuild/blob/main/CONTRIBUTING.md).
15
+ See [Documentation](https://rsbuild.dev/plugins/list/plugin-vue).
16
16
 
17
17
  ## License
18
18
 
19
- Rsbuild is [MIT licensed](https://github.com/web-infra-dev/rsbuild/blob/main/LICENSE).
19
+ [MIT](https://github.com/web-infra-dev/rsbuild/blob/main/LICENSE).
package/dist/index.cjs CHANGED
@@ -1,127 +1,88 @@
1
1
  "use strict";
2
- // The require scope
2
+ let __rslib_import_meta_url__ = 'undefined' == typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
3
3
  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
4
+ __webpack_require__.d = function(exports1, definition) {
5
+ for(var key in definition)__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key) && Object.defineProperty(exports1, key, {
6
+ enumerable: !0,
7
+ get: definition[key]
8
+ });
9
+ }, __webpack_require__.o = function(obj, prop) {
10
+ return Object.prototype.hasOwnProperty.call(obj, prop);
11
+ }, __webpack_require__.r = function(exports1) {
12
+ 'undefined' != typeof Symbol && Symbol.toStringTag && Object.defineProperty(exports1, Symbol.toStringTag, {
13
+ value: 'Module'
14
+ }), Object.defineProperty(exports1, '__esModule', {
15
+ value: !0
16
+ });
17
+ };
18
+ var __webpack_exports__ = {};
19
+ __webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_exports__, {
20
+ pluginVue: ()=>pluginVue,
21
+ PLUGIN_VUE_NAME: ()=>PLUGIN_VUE_NAME
38
22
  });
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
23
+ 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 = {
24
+ vue: !0,
25
+ router: !0
45
26
  })=>{
46
27
  api.modifyBundlerChain((chain, { environment })=>{
47
- const { config } = environment;
28
+ let { config } = environment;
48
29
  if ('split-by-experience' !== config.performance.chunkSplit.strategy) return;
49
- const currentConfig = chain.optimization.splitChunks.values();
30
+ let currentConfig = chain.optimization.splitChunks.values();
50
31
  if (!isPlainObject(currentConfig)) return;
51
- const extraGroups = {};
52
- if (options.vue) extraGroups.vue = {
32
+ let extraGroups = {};
33
+ options.vue && (extraGroups.vue = {
53
34
  name: 'lib-vue',
54
35
  test: /node_modules[\\/](?:vue|vue-loader|@vue[\\/]shared|@vue[\\/]reactivity|@vue[\\/]runtime-dom|@vue[\\/]runtime-core)[\\/]/,
55
36
  priority: 0
56
- };
57
- if (options.router) extraGroups.router = {
37
+ }), options.router && (extraGroups.router = {
58
38
  name: 'lib-router',
59
39
  test: /node_modules[\\/]vue-router[\\/]/,
60
40
  priority: 0
61
- };
62
- if (!Object.keys(extraGroups).length) return;
63
- chain.optimization.splitChunks({
41
+ }), Object.keys(extraGroups).length && chain.optimization.splitChunks({
64
42
  ...currentConfig,
65
43
  cacheGroups: {
66
- // user defined cache groups take precedence
67
44
  ...extraGroups,
68
45
  ...currentConfig.cacheGroups
69
46
  }
70
47
  });
71
48
  });
72
- };
73
- const src_require = (0, external_node_module_namespaceObject.createRequire)(/*#__PURE__*/ function() {
74
- 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;
75
- }());
76
- const PLUGIN_VUE_NAME = 'rsbuild:vue';
49
+ }, src_require = (0, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__), PLUGIN_VUE_NAME = 'rsbuild:vue';
77
50
  function pluginVue(options = {}) {
78
51
  return {
79
52
  name: PLUGIN_VUE_NAME,
80
53
  setup (api) {
81
- const VUE_REGEXP = /\.vue$/;
82
- const CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
54
+ let VUE_REGEXP = /\.vue$/, CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
83
55
  api.modifyEnvironmentConfig((config, { mergeEnvironmentConfig })=>{
84
- const extraConfig = {
56
+ let merged = mergeEnvironmentConfig({
85
57
  source: {
86
58
  define: {
87
- // https://link.vuejs.org/feature-flags
88
- __VUE_OPTIONS_API__: true,
89
- __VUE_PROD_DEVTOOLS__: false,
90
- __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false
91
- }
59
+ __VUE_OPTIONS_API__: !0,
60
+ __VUE_PROD_DEVTOOLS__: !1,
61
+ __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: !1
62
+ },
63
+ include: [
64
+ /\.vue.js$/
65
+ ]
92
66
  }
93
- };
94
- const merged = mergeEnvironmentConfig(extraConfig, config);
95
- // Support `<style module>` in Vue SFC
96
- if (true === merged.output.cssModules.auto) merged.output.cssModules.auto = (path, query)=>{
97
- if (VUE_REGEXP.test(path)) return query.includes('type=style') && query.includes('module=true');
98
- return CSS_MODULES_REGEX.test(path);
99
- };
100
- return merged;
101
- });
102
- api.modifyBundlerChain(async (chain, { CHAIN_ID })=>{
67
+ }, config);
68
+ 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;
69
+ }), api.modifyBundlerChain(async (chain, { CHAIN_ID })=>{
103
70
  chain.resolve.extensions.add('.vue');
104
- const userLoaderOptions = options.vueLoaderOptions ?? {};
105
- const compilerOptions = {
106
- preserveWhitespace: false,
71
+ let userLoaderOptions = options.vueLoaderOptions ?? {}, compilerOptions = {
72
+ preserveWhitespace: !1,
107
73
  ...userLoaderOptions.compilerOptions
108
- };
109
- const vueLoaderOptions = {
110
- experimentalInlineMatchResource: true,
74
+ }, vueLoaderOptions = {
75
+ experimentalInlineMatchResource: !0,
111
76
  ...userLoaderOptions,
112
77
  compilerOptions
113
78
  };
114
- chain.module.rule(CHAIN_ID.RULE.VUE).test(VUE_REGEXP).use(CHAIN_ID.USE.VUE).loader(src_require.resolve('vue-loader')).options(vueLoaderOptions);
115
- // Support for lang="postcss" and lang="pcss" in SFC
116
- chain.module.rule(CHAIN_ID.RULE.CSS).test(/\.(?:css|postcss|pcss)$/);
117
- chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_PLUGIN).use(external_vue_loader_namespaceObject.VueLoaderPlugin);
118
- });
119
- applySplitChunksRule(api, options.splitChunks);
79
+ 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);
80
+ }), applySplitChunksRule(api, options.splitChunks);
120
81
  }
121
82
  };
122
83
  }
123
84
  var __webpack_export_target__ = exports;
124
- for(var i in __webpack_exports__)__webpack_export_target__[i] = __webpack_exports__[i];
125
- if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
126
- value: true
85
+ for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
86
+ __webpack_exports__.__esModule && Object.defineProperty(__webpack_export_target__, '__esModule', {
87
+ value: !0
127
88
  });
package/dist/index.js CHANGED
@@ -1,82 +1,63 @@
1
- import * as __WEBPACK_EXTERNAL_MODULE_node_module__ from "node:module";
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
1
+ import * as __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__ from "node:module";
2
+ import * as __WEBPACK_EXTERNAL_MODULE_vue_loader_a33e643c__ from "vue-loader";
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
+ 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
- // user defined cache groups take precedence
29
24
  ...extraGroups,
30
25
  ...currentConfig.cacheGroups
31
26
  }
32
27
  });
33
28
  });
34
- };
35
- const src_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module__.createRequire)(import.meta.url);
36
- const PLUGIN_VUE_NAME = 'rsbuild:vue';
29
+ }, src_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__.createRequire)(import.meta.url), PLUGIN_VUE_NAME = 'rsbuild:vue';
37
30
  function pluginVue(options = {}) {
38
31
  return {
39
32
  name: PLUGIN_VUE_NAME,
40
33
  setup (api) {
41
- const VUE_REGEXP = /\.vue$/;
42
- const CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
34
+ let VUE_REGEXP = /\.vue$/, CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
43
35
  api.modifyEnvironmentConfig((config, { mergeEnvironmentConfig })=>{
44
- const extraConfig = {
36
+ let merged = mergeEnvironmentConfig({
45
37
  source: {
46
38
  define: {
47
- // https://link.vuejs.org/feature-flags
48
- __VUE_OPTIONS_API__: true,
49
- __VUE_PROD_DEVTOOLS__: false,
50
- __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false
51
- }
39
+ __VUE_OPTIONS_API__: !0,
40
+ __VUE_PROD_DEVTOOLS__: !1,
41
+ __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: !1
42
+ },
43
+ include: [
44
+ /\.vue.js$/
45
+ ]
52
46
  }
53
- };
54
- const merged = mergeEnvironmentConfig(extraConfig, config);
55
- // Support `<style module>` in Vue SFC
56
- if (true === merged.output.cssModules.auto) merged.output.cssModules.auto = (path, query)=>{
57
- if (VUE_REGEXP.test(path)) return query.includes('type=style') && query.includes('module=true');
58
- return CSS_MODULES_REGEX.test(path);
59
- };
60
- return merged;
61
- });
62
- 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 })=>{
63
50
  chain.resolve.extensions.add('.vue');
64
- const userLoaderOptions = options.vueLoaderOptions ?? {};
65
- const compilerOptions = {
66
- preserveWhitespace: false,
51
+ let userLoaderOptions = options.vueLoaderOptions ?? {}, compilerOptions = {
52
+ preserveWhitespace: !1,
67
53
  ...userLoaderOptions.compilerOptions
68
- };
69
- const vueLoaderOptions = {
70
- experimentalInlineMatchResource: true,
54
+ }, vueLoaderOptions = {
55
+ experimentalInlineMatchResource: !0,
71
56
  ...userLoaderOptions,
72
57
  compilerOptions
73
58
  };
74
- chain.module.rule(CHAIN_ID.RULE.VUE).test(VUE_REGEXP).use(CHAIN_ID.USE.VUE).loader(src_require.resolve('vue-loader')).options(vueLoaderOptions);
75
- // Support for lang="postcss" and lang="pcss" in SFC
76
- chain.module.rule(CHAIN_ID.RULE.CSS).test(/\.(?:css|postcss|pcss)$/);
77
- chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_PLUGIN).use(__WEBPACK_EXTERNAL_MODULE_vue_loader__.VueLoaderPlugin);
78
- });
79
- 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_a33e643c__.VueLoaderPlugin);
60
+ }), applySplitChunksRule(api, options.splitChunks);
80
61
  }
81
62
  };
82
63
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-vue",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
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.96.1"
27
+ "webpack": "^5.98.0"
28
28
  },
29
29
  "devDependencies": {
30
- "typescript": "^5.6.3",
31
- "vue": "^3.5.12",
32
- "webpack": "^5.96.1",
33
- "@rsbuild/core": "1.1.0",
30
+ "@rslib/core": "0.4.1",
31
+ "@types/node": "^22.13.4",
32
+ "typescript": "^5.7.3",
33
+ "vue": "^3.5.13",
34
+ "webpack": "^5.98.0",
35
+ "@rsbuild/core": "1.2.9",
34
36
  "@scripts/test-helper": "1.0.1"
35
37
  },
36
38
  "peerDependencies": {