@rsbuild/plugin-vue 2.0.0-alpha.3 → 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 +15 -20
- package/dist/index.js +13 -6
- package/package.json +28 -24
- package/dist/index.cjs +0 -99
package/dist/index.d.ts
CHANGED
|
@@ -2,31 +2,26 @@ import type { RsbuildPlugin, Rspack } from '@rsbuild/core';
|
|
|
2
2
|
import { type VueLoaderOptions } from 'rspack-vue-loader';
|
|
3
3
|
export type SplitVueChunkOptions = {
|
|
4
4
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
vue?: boolean;
|
|
5
|
+
* Whether to enable split chunking for Vue-related dependencies (e.g., vue, rspack-vue-loader).
|
|
6
|
+
* @default true
|
|
7
|
+
*/ vue?: boolean;
|
|
9
8
|
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
router?: boolean;
|
|
9
|
+
* Whether to enable split chunking for vue-router.
|
|
10
|
+
* @default true
|
|
11
|
+
*/ router?: boolean;
|
|
14
12
|
};
|
|
15
13
|
export type PluginVueOptions = {
|
|
16
14
|
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
test?: Rspack.RuleSetCondition;
|
|
15
|
+
* Test condition to match Vue files.
|
|
16
|
+
* @default /\.vue$/
|
|
17
|
+
*/ test?: Rspack.RuleSetCondition;
|
|
21
18
|
/**
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
vueLoaderOptions?: VueLoaderOptions;
|
|
19
|
+
* Options passed to `rspack-vue-loader`.
|
|
20
|
+
* @see https://vue-loader.vuejs.org/
|
|
21
|
+
*/ vueLoaderOptions?: VueLoaderOptions;
|
|
26
22
|
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
splitChunks?: SplitVueChunkOptions;
|
|
23
|
+
* This option is used to control the split chunks behavior.
|
|
24
|
+
*/ splitChunks?: SplitVueChunkOptions;
|
|
30
25
|
};
|
|
31
|
-
export declare const PLUGIN_VUE_NAME =
|
|
26
|
+
export declare const PLUGIN_VUE_NAME = 'rsbuild:vue';
|
|
32
27
|
export declare function pluginVue(options?: PluginVueOptions): RsbuildPlugin;
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,10 @@ function applySplitChunksRule(api, options = {
|
|
|
6
6
|
}) {
|
|
7
7
|
api.modifyBundlerChain((chain, { environment })=>{
|
|
8
8
|
let { config } = environment;
|
|
9
|
-
if (
|
|
9
|
+
if (!((config)=>{
|
|
10
|
+
let { performance, splitChunks } = config;
|
|
11
|
+
return performance.chunkSplit ? performance.chunkSplit?.strategy === 'split-by-experience' : 'object' == typeof splitChunks && (!splitChunks.preset || 'default' === splitChunks.preset);
|
|
12
|
+
})(config) || 'web' !== config.output.target) return;
|
|
10
13
|
let currentConfig = chain.optimization.splitChunks.values();
|
|
11
14
|
if (null === currentConfig || 'object' != typeof currentConfig || '[object Object]' !== Object.prototype.toString.call(currentConfig)) return;
|
|
12
15
|
let extraGroups = {};
|
|
@@ -28,11 +31,15 @@ function applySplitChunksRule(api, options = {
|
|
|
28
31
|
});
|
|
29
32
|
}
|
|
30
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
|
+
}
|
|
31
37
|
function pluginVue(options = {}) {
|
|
32
38
|
return {
|
|
33
39
|
name: PLUGIN_VUE_NAME,
|
|
34
40
|
setup (api) {
|
|
35
|
-
|
|
41
|
+
assertCoreVersion(api.context.version);
|
|
42
|
+
let { test = /\.vue$/ } = options, CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
|
|
36
43
|
api.modifyEnvironmentConfig((config, { mergeEnvironmentConfig })=>{
|
|
37
44
|
let merged = mergeEnvironmentConfig({
|
|
38
45
|
source: {
|
|
@@ -47,7 +54,7 @@ function pluginVue(options = {}) {
|
|
|
47
54
|
}
|
|
48
55
|
}, config);
|
|
49
56
|
return !0 === merged.output.cssModules.auto && (merged.output.cssModules.auto = (path, query)=>{
|
|
50
|
-
if ((
|
|
57
|
+
if ((path.endsWith('.vue') || path.includes('.vue.css')) && query) try {
|
|
51
58
|
let params = new URLSearchParams(query);
|
|
52
59
|
return 'style' === params.get('type') && params.has('module');
|
|
53
60
|
} catch {
|
|
@@ -55,14 +62,14 @@ function pluginVue(options = {}) {
|
|
|
55
62
|
}
|
|
56
63
|
return CSS_MODULES_REGEX.test(path);
|
|
57
64
|
}), merged;
|
|
58
|
-
}), api.modifyBundlerChain((chain, { CHAIN_ID })=>{
|
|
65
|
+
}), api.modifyBundlerChain((chain, { CHAIN_ID, environment, target })=>{
|
|
59
66
|
chain.resolve.extensions.add('.vue');
|
|
60
67
|
let userLoaderOptions = options.vueLoaderOptions ?? {}, compilerOptions = {
|
|
61
68
|
preserveWhitespace: !1,
|
|
62
69
|
...userLoaderOptions.compilerOptions
|
|
63
|
-
}, vueLoaderOptions = {
|
|
70
|
+
}, emitCss = environment.config.output.emitCss ?? 'web' === target, vueLoaderOptions = {
|
|
64
71
|
isServerBuild: 'rstest' !== api.context.callerName && void 0,
|
|
65
|
-
experimentalInlineMatchResource:
|
|
72
|
+
experimentalInlineMatchResource: emitCss,
|
|
66
73
|
...userLoaderOptions,
|
|
67
74
|
compilerOptions
|
|
68
75
|
};
|
package/package.json
CHANGED
|
@@ -1,49 +1,53 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-vue",
|
|
3
|
-
"version": "2.0.0
|
|
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
|
-
"
|
|
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
|
-
"
|
|
17
|
-
"require": "./dist/index.cjs"
|
|
23
|
+
"default": "./dist/index.js"
|
|
18
24
|
}
|
|
19
25
|
},
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
],
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public",
|
|
28
|
+
"registry": "https://registry.npmjs.org/"
|
|
29
|
+
},
|
|
25
30
|
"dependencies": {
|
|
26
|
-
"rspack-vue-loader": "^17.
|
|
27
|
-
"webpack": "^5.104.1"
|
|
31
|
+
"rspack-vue-loader": "^17.5.1"
|
|
28
32
|
},
|
|
29
33
|
"devDependencies": {
|
|
30
|
-
"@rslib/core": "0.
|
|
31
|
-
"@types/node": "^24.
|
|
32
|
-
"typescript": "^
|
|
33
|
-
"vue": "^3.5.
|
|
34
|
-
"@
|
|
35
|
-
"@
|
|
34
|
+
"@rslib/core": "0.23.0",
|
|
35
|
+
"@types/node": "^24.13.2",
|
|
36
|
+
"typescript": "^6.0.3",
|
|
37
|
+
"vue": "^3.5.38",
|
|
38
|
+
"@rsbuild/core": "2.1.0-beta.0",
|
|
39
|
+
"@scripts/test-helper": "1.0.0"
|
|
36
40
|
},
|
|
37
41
|
"peerDependencies": {
|
|
38
|
-
"@rsbuild/core": "^2.0.0
|
|
42
|
+
"@rsbuild/core": "^2.0.0"
|
|
39
43
|
},
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
|
|
44
|
+
"peerDependenciesMeta": {
|
|
45
|
+
"@rsbuild/core": {
|
|
46
|
+
"optional": true
|
|
47
|
+
}
|
|
43
48
|
},
|
|
44
49
|
"scripts": {
|
|
45
|
-
"build": "rslib
|
|
46
|
-
"dev": "rslib
|
|
47
|
-
"bump": "pnpx bumpp --no-tag"
|
|
50
|
+
"build": "rslib",
|
|
51
|
+
"dev": "rslib -w"
|
|
48
52
|
}
|
|
49
53
|
}
|
package/dist/index.cjs
DELETED
|
@@ -1,99 +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, 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 = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop), __webpack_require__.r = (exports1)=>{
|
|
10
|
-
"u" > typeof Symbol && Symbol.toStringTag && Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
11
|
-
value: 'Module'
|
|
12
|
-
}), Object.defineProperty(exports1, '__esModule', {
|
|
13
|
-
value: !0
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
var __webpack_exports__ = {};
|
|
17
|
-
__webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_exports__, {
|
|
18
|
-
PLUGIN_VUE_NAME: ()=>PLUGIN_VUE_NAME,
|
|
19
|
-
pluginVue: ()=>pluginVue
|
|
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);
|
|
22
|
-
function applySplitChunksRule(api, options = {
|
|
23
|
-
vue: !0,
|
|
24
|
-
router: !0
|
|
25
|
-
}) {
|
|
26
|
-
api.modifyBundlerChain((chain, { environment })=>{
|
|
27
|
-
let { config } = environment;
|
|
28
|
-
if ('split-by-experience' !== config.performance.chunkSplit.strategy) return;
|
|
29
|
-
let currentConfig = chain.optimization.splitChunks.values();
|
|
30
|
-
if (!isPlainObject(currentConfig)) return;
|
|
31
|
-
let extraGroups = {};
|
|
32
|
-
options.vue && (extraGroups.vue = {
|
|
33
|
-
name: 'lib-vue',
|
|
34
|
-
test: /node_modules[\\/](?:vue|rspack-vue-loader|@vue[\\/]shared|@vue[\\/]reactivity|@vue[\\/]runtime-dom|@vue[\\/]runtime-core)[\\/]/,
|
|
35
|
-
priority: 0
|
|
36
|
-
}), options.router && (extraGroups.router = {
|
|
37
|
-
name: 'lib-router',
|
|
38
|
-
test: /node_modules[\\/]vue-router[\\/]/,
|
|
39
|
-
priority: 0
|
|
40
|
-
}), Object.keys(extraGroups).length && chain.optimization.splitChunks({
|
|
41
|
-
...currentConfig,
|
|
42
|
-
cacheGroups: {
|
|
43
|
-
...extraGroups,
|
|
44
|
-
...currentConfig.cacheGroups
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
const src_require = (0, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__), PLUGIN_VUE_NAME = 'rsbuild:vue';
|
|
50
|
-
function pluginVue(options = {}) {
|
|
51
|
-
return {
|
|
52
|
-
name: PLUGIN_VUE_NAME,
|
|
53
|
-
setup (api) {
|
|
54
|
-
let VUE_REGEXP = /\.vue$/, { test = VUE_REGEXP } = options, CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
|
|
55
|
-
api.modifyEnvironmentConfig((config, { mergeEnvironmentConfig })=>{
|
|
56
|
-
let merged = mergeEnvironmentConfig({
|
|
57
|
-
source: {
|
|
58
|
-
define: {
|
|
59
|
-
__VUE_OPTIONS_API__: !0,
|
|
60
|
-
__VUE_PROD_DEVTOOLS__: !1,
|
|
61
|
-
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: !1
|
|
62
|
-
},
|
|
63
|
-
include: [
|
|
64
|
-
/\.vue.js$/
|
|
65
|
-
]
|
|
66
|
-
}
|
|
67
|
-
}, config);
|
|
68
|
-
return !0 === merged.output.cssModules.auto && (merged.output.cssModules.auto = (path, query)=>{
|
|
69
|
-
if ((VUE_REGEXP.test(path) || path.includes('.vue.css')) && query) try {
|
|
70
|
-
let params = new URLSearchParams(query);
|
|
71
|
-
return 'style' === params.get('type') && params.has('module');
|
|
72
|
-
} catch {
|
|
73
|
-
return !1;
|
|
74
|
-
}
|
|
75
|
-
return CSS_MODULES_REGEX.test(path);
|
|
76
|
-
}), merged;
|
|
77
|
-
}), api.modifyBundlerChain((chain, { CHAIN_ID })=>{
|
|
78
|
-
chain.resolve.extensions.add('.vue');
|
|
79
|
-
let userLoaderOptions = options.vueLoaderOptions ?? {}, compilerOptions = {
|
|
80
|
-
preserveWhitespace: !1,
|
|
81
|
-
...userLoaderOptions.compilerOptions
|
|
82
|
-
}, vueLoaderOptions = {
|
|
83
|
-
isServerBuild: 'rstest' !== api.context.callerName && void 0,
|
|
84
|
-
experimentalInlineMatchResource: !0,
|
|
85
|
-
...userLoaderOptions,
|
|
86
|
-
compilerOptions
|
|
87
|
-
};
|
|
88
|
-
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);
|
|
89
|
-
}), applySplitChunksRule(api, options.splitChunks);
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
for(var __rspack_i in exports.PLUGIN_VUE_NAME = __webpack_exports__.PLUGIN_VUE_NAME, exports.pluginVue = __webpack_exports__.pluginVue, __webpack_exports__)-1 === [
|
|
94
|
-
"PLUGIN_VUE_NAME",
|
|
95
|
-
"pluginVue"
|
|
96
|
-
].indexOf(__rspack_i) && (exports[__rspack_i] = __webpack_exports__[__rspack_i]);
|
|
97
|
-
Object.defineProperty(exports, '__esModule', {
|
|
98
|
-
value: !0
|
|
99
|
-
});
|