@rsbuild/plugin-vue 1.2.9 → 2.0.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.
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import type { RsbuildPlugin, Rspack } from '@rsbuild/core';
2
2
  import { type VueLoaderOptions } from 'rspack-vue-loader';
3
3
  export type SplitVueChunkOptions = {
4
4
  /**
5
- * Whether to enable split chunking for Vue-related dependencies (e.g., vue, vue-loader).
5
+ * Whether to enable split chunking for Vue-related dependencies (e.g., vue, rspack-vue-loader).
6
6
  * @default true
7
7
  */ vue?: boolean;
8
8
  /**
@@ -16,7 +16,7 @@ export type PluginVueOptions = {
16
16
  * @default /\.vue$/
17
17
  */ test?: Rspack.RuleSetCondition;
18
18
  /**
19
- * Options passed to `vue-loader`.
19
+ * Options passed to `rspack-vue-loader`.
20
20
  * @see https://vue-loader.vuejs.org/
21
21
  */ vueLoaderOptions?: VueLoaderOptions;
22
22
  /**
package/dist/index.js CHANGED
@@ -31,10 +31,14 @@ function applySplitChunksRule(api, options = {
31
31
  });
32
32
  }
33
33
  let src_require = createRequire(import.meta.url), PLUGIN_VUE_NAME = 'rsbuild:vue';
34
+ function assertCoreVersion(version) {
35
+ if ('1' === version.split('.')[0]) throw Error('"@rsbuild/plugin-vue" v2 requires "@rsbuild/core" >= 2.0. Please upgrade "@rsbuild/core" or use "@rsbuild/plugin-vue" v1.');
36
+ }
34
37
  function pluginVue(options = {}) {
35
38
  return {
36
39
  name: PLUGIN_VUE_NAME,
37
40
  setup (api) {
41
+ assertCoreVersion(api.context.version);
38
42
  let { test = /\.vue$/ } = options, CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
39
43
  api.modifyEnvironmentConfig((config, { mergeEnvironmentConfig })=>{
40
44
  let merged = mergeEnvironmentConfig({
package/package.json CHANGED
@@ -1,50 +1,51 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-vue",
3
- "version": "1.2.9",
3
+ "version": "2.0.0",
4
4
  "description": "Vue 3 plugin of Rsbuild",
5
5
  "homepage": "https://rsbuild.rs",
6
+ "bugs": {
7
+ "url": "https://github.com/web-infra-dev/rsbuild/issues"
8
+ },
9
+ "license": "MIT",
6
10
  "repository": {
7
11
  "type": "git",
8
12
  "url": "https://github.com/web-infra-dev/rsbuild",
9
13
  "directory": "packages/plugin-vue"
10
14
  },
11
- "license": "MIT",
15
+ "files": [
16
+ "dist"
17
+ ],
12
18
  "type": "module",
19
+ "types": "./dist/index.d.ts",
13
20
  "exports": {
14
21
  ".": {
15
22
  "types": "./dist/index.d.ts",
16
- "import": "./dist/index.js",
17
- "require": "./dist/index.cjs"
23
+ "default": "./dist/index.js"
18
24
  }
19
25
  },
20
- "types": "./dist/index.d.ts",
21
- "files": [
22
- "dist"
23
- ],
26
+ "publishConfig": {
27
+ "access": "public",
28
+ "registry": "https://registry.npmjs.org/"
29
+ },
24
30
  "dependencies": {
25
- "rspack-vue-loader": "^17.5.0"
31
+ "rspack-vue-loader": "^17.5.1"
26
32
  },
27
33
  "devDependencies": {
28
- "@rsbuild/core-v1": "npm:@rsbuild/core@^1.7.5",
29
- "@rslib/core": "0.22.0",
30
- "@types/node": "^24.12.4",
34
+ "@rslib/core": "0.23.0",
35
+ "@types/node": "^24.13.2",
31
36
  "typescript": "^6.0.3",
32
- "vue": "^3.5.34",
33
- "@rsbuild/core": "2.0.9",
37
+ "vue": "^3.5.38",
38
+ "@rsbuild/core": "2.1.0-beta.0",
34
39
  "@scripts/test-helper": "1.0.0"
35
40
  },
36
41
  "peerDependencies": {
37
- "@rsbuild/core": "^1.0.0 || ^2.0.0-0"
42
+ "@rsbuild/core": "^2.0.0"
38
43
  },
39
44
  "peerDependenciesMeta": {
40
45
  "@rsbuild/core": {
41
46
  "optional": true
42
47
  }
43
48
  },
44
- "publishConfig": {
45
- "access": "public",
46
- "registry": "https://registry.npmjs.org/"
47
- },
48
49
  "scripts": {
49
50
  "build": "rslib",
50
51
  "dev": "rslib -w"
package/dist/index.cjs DELETED
@@ -1,105 +0,0 @@
1
- "use strict";
2
- const __rslib_import_meta_url__ = "u" < typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
3
- var __webpack_require__ = {};
4
- __webpack_require__.d = (exports1, getters, values)=>{
5
- var define = (defs, kind)=>{
6
- for(var key in defs)__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key) && Object.defineProperty(exports1, key, {
7
- enumerable: !0,
8
- [kind]: defs[key]
9
- });
10
- };
11
- define(getters, "get"), define(values, "value");
12
- }, __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop), __webpack_require__.r = (exports1)=>{
13
- "u" > typeof Symbol && Symbol.toStringTag && Object.defineProperty(exports1, Symbol.toStringTag, {
14
- value: 'Module'
15
- }), Object.defineProperty(exports1, '__esModule', {
16
- value: !0
17
- });
18
- };
19
- var __webpack_exports__ = {};
20
- __webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_exports__, {
21
- PLUGIN_VUE_NAME: ()=>PLUGIN_VUE_NAME,
22
- pluginVue: ()=>pluginVue
23
- });
24
- 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)=>{
25
- let { performance, splitChunks } = config;
26
- return performance.chunkSplit ? performance.chunkSplit?.strategy === 'split-by-experience' : 'object' == typeof splitChunks && (!splitChunks.preset || 'default' === splitChunks.preset);
27
- };
28
- function applySplitChunksRule(api, options = {
29
- vue: !0,
30
- router: !0
31
- }) {
32
- api.modifyBundlerChain((chain, { environment })=>{
33
- let { config } = environment;
34
- if (!isDefaultPreset(config) || 'web' !== config.output.target) return;
35
- let currentConfig = chain.optimization.splitChunks.values();
36
- if (!isPlainObject(currentConfig)) return;
37
- let extraGroups = {};
38
- options.vue && (extraGroups.vue = {
39
- name: 'lib-vue',
40
- test: /node_modules[\\/](?:vue|rspack-vue-loader|@vue[\\/]shared|@vue[\\/]reactivity|@vue[\\/]runtime-dom|@vue[\\/]runtime-core)[\\/]/,
41
- priority: 0
42
- }), options.router && (extraGroups.router = {
43
- name: 'lib-router',
44
- test: /node_modules[\\/]vue-router[\\/]/,
45
- priority: 0
46
- }), Object.keys(extraGroups).length && chain.optimization.splitChunks({
47
- ...currentConfig,
48
- cacheGroups: {
49
- ...extraGroups,
50
- ...currentConfig.cacheGroups
51
- }
52
- });
53
- });
54
- }
55
- const src_require = (0, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__), PLUGIN_VUE_NAME = 'rsbuild:vue';
56
- function pluginVue(options = {}) {
57
- return {
58
- name: PLUGIN_VUE_NAME,
59
- setup (api) {
60
- let { test = /\.vue$/ } = options, CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
61
- api.modifyEnvironmentConfig((config, { mergeEnvironmentConfig })=>{
62
- let merged = mergeEnvironmentConfig({
63
- source: {
64
- define: {
65
- __VUE_OPTIONS_API__: !0,
66
- __VUE_PROD_DEVTOOLS__: !1,
67
- __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: !1
68
- },
69
- include: [
70
- /\.vue.js$/
71
- ]
72
- }
73
- }, config);
74
- return !0 === merged.output.cssModules.auto && (merged.output.cssModules.auto = (path, query)=>{
75
- if ((path.endsWith('.vue') || path.includes('.vue.css')) && query) try {
76
- let params = new URLSearchParams(query);
77
- return 'style' === params.get('type') && params.has('module');
78
- } catch {
79
- return !1;
80
- }
81
- return CSS_MODULES_REGEX.test(path);
82
- }), merged;
83
- }), api.modifyBundlerChain((chain, { CHAIN_ID, environment, target })=>{
84
- chain.resolve.extensions.add('.vue');
85
- let userLoaderOptions = options.vueLoaderOptions ?? {}, compilerOptions = {
86
- preserveWhitespace: !1,
87
- ...userLoaderOptions.compilerOptions
88
- }, emitCss = environment.config.output.emitCss ?? 'web' === target, vueLoaderOptions = {
89
- isServerBuild: 'rstest' !== api.context.callerName && void 0,
90
- experimentalInlineMatchResource: emitCss,
91
- ...userLoaderOptions,
92
- compilerOptions
93
- };
94
- 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(external_rspack_vue_loader_namespaceObject.VueLoaderPlugin);
95
- }), applySplitChunksRule(api, options.splitChunks);
96
- }
97
- };
98
- }
99
- for(var __rspack_i in exports.PLUGIN_VUE_NAME = __webpack_exports__.PLUGIN_VUE_NAME, exports.pluginVue = __webpack_exports__.pluginVue, __webpack_exports__)-1 === [
100
- "PLUGIN_VUE_NAME",
101
- "pluginVue"
102
- ].indexOf(__rspack_i) && (exports[__rspack_i] = __webpack_exports__[__rspack_i]);
103
- Object.defineProperty(exports, '__esModule', {
104
- value: !0
105
- });