@rsbuild/plugin-vue 1.0.4 → 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 +48 -88
- package/dist/index.js +28 -47
- package/package.json +4 -2
package/dist/index.cjs
CHANGED
|
@@ -1,127 +1,87 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// The require scope
|
|
3
2
|
var __webpack_require__ = {};
|
|
4
|
-
|
|
5
|
-
(()
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
(
|
|
21
|
-
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
|
|
27
|
+
let { config } = environment;
|
|
48
28
|
if ('split-by-experience' !== config.performance.chunkSplit.strategy) return;
|
|
49
|
-
|
|
29
|
+
let currentConfig = chain.optimization.splitChunks.values();
|
|
50
30
|
if (!isPlainObject(currentConfig)) return;
|
|
51
|
-
|
|
52
|
-
if (options.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
|
-
// user defined cache groups take precedence
|
|
67
43
|
...extraGroups,
|
|
68
44
|
...currentConfig.cacheGroups
|
|
69
45
|
}
|
|
70
46
|
});
|
|
71
47
|
});
|
|
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';
|
|
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';
|
|
77
49
|
function pluginVue(options = {}) {
|
|
78
50
|
return {
|
|
79
51
|
name: PLUGIN_VUE_NAME,
|
|
80
52
|
setup (api) {
|
|
81
|
-
|
|
82
|
-
const CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
|
|
53
|
+
let VUE_REGEXP = /\.vue$/, CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
|
|
83
54
|
api.modifyEnvironmentConfig((config, { mergeEnvironmentConfig })=>{
|
|
84
|
-
|
|
55
|
+
let merged = mergeEnvironmentConfig({
|
|
85
56
|
source: {
|
|
86
57
|
define: {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
58
|
+
__VUE_OPTIONS_API__: !0,
|
|
59
|
+
__VUE_PROD_DEVTOOLS__: !1,
|
|
60
|
+
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: !1
|
|
61
|
+
},
|
|
62
|
+
include: [
|
|
63
|
+
/\.vue.js$/
|
|
64
|
+
]
|
|
92
65
|
}
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
|
|
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 })=>{
|
|
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 })=>{
|
|
103
69
|
chain.resolve.extensions.add('.vue');
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
preserveWhitespace: false,
|
|
70
|
+
let userLoaderOptions = options.vueLoaderOptions ?? {}, compilerOptions = {
|
|
71
|
+
preserveWhitespace: !1,
|
|
107
72
|
...userLoaderOptions.compilerOptions
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
experimentalInlineMatchResource: true,
|
|
73
|
+
}, vueLoaderOptions = {
|
|
74
|
+
experimentalInlineMatchResource: !0,
|
|
111
75
|
...userLoaderOptions,
|
|
112
76
|
compilerOptions
|
|
113
77
|
};
|
|
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
|
-
|
|
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);
|
|
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);
|
|
120
80
|
}
|
|
121
81
|
};
|
|
122
82
|
}
|
|
123
83
|
var __webpack_export_target__ = exports;
|
|
124
84
|
for(var i in __webpack_exports__)__webpack_export_target__[i] = __webpack_exports__[i];
|
|
125
|
-
|
|
126
|
-
value:
|
|
85
|
+
__webpack_exports__.__esModule && Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
86
|
+
value: !0
|
|
127
87
|
});
|
package/dist/index.js
CHANGED
|
@@ -1,82 +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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
8
|
+
let { config } = environment;
|
|
10
9
|
if ('split-by-experience' !== config.performance.chunkSplit.strategy) return;
|
|
11
|
-
|
|
10
|
+
let currentConfig = chain.optimization.splitChunks.values();
|
|
12
11
|
if (!isPlainObject(currentConfig)) return;
|
|
13
|
-
|
|
14
|
-
if (options.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
|
-
// 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__.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
|
-
|
|
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
|
-
|
|
36
|
+
let merged = mergeEnvironmentConfig({
|
|
45
37
|
source: {
|
|
46
38
|
define: {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
55
|
-
|
|
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
|
-
|
|
65
|
-
|
|
66
|
-
preserveWhitespace: false,
|
|
51
|
+
let userLoaderOptions = options.vueLoaderOptions ?? {}, compilerOptions = {
|
|
52
|
+
preserveWhitespace: !1,
|
|
67
53
|
...userLoaderOptions.compilerOptions
|
|
68
|
-
}
|
|
69
|
-
|
|
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
|
-
|
|
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__.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.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Vue 3 plugin of Rsbuild",
|
|
5
5
|
"homepage": "https://rsbuild.dev",
|
|
6
6
|
"repository": {
|
|
@@ -27,10 +27,12 @@
|
|
|
27
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
34
|
"webpack": "^5.96.1",
|
|
33
|
-
"@rsbuild/core": "1.1.
|
|
35
|
+
"@rsbuild/core": "1.1.2",
|
|
34
36
|
"@scripts/test-helper": "1.0.1"
|
|
35
37
|
},
|
|
36
38
|
"peerDependencies": {
|