@rsbuild/plugin-vue2 1.0.2 → 1.0.3
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 +20 -36
- package/dist/index.js +7 -19
- package/package.json +11 -12
package/dist/index.cjs
CHANGED
|
@@ -1,25 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
const __rslib_import_meta_url__ = /*#__PURE__*/ function() {
|
|
3
|
+
return 'undefined' == typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
|
|
4
|
+
}();
|
|
3
5
|
var __webpack_require__ = {};
|
|
4
|
-
/************************************************************************/ // webpack/runtime/define_property_getters
|
|
5
6
|
(()=>{
|
|
6
|
-
__webpack_require__.d =
|
|
7
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
7
8
|
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
8
9
|
enumerable: true,
|
|
9
10
|
get: definition[key]
|
|
10
11
|
});
|
|
11
12
|
};
|
|
12
13
|
})();
|
|
13
|
-
// webpack/runtime/has_own_property
|
|
14
14
|
(()=>{
|
|
15
|
-
__webpack_require__.o =
|
|
16
|
-
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
-
};
|
|
15
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
18
16
|
})();
|
|
19
|
-
// webpack/runtime/make_namespace_object
|
|
20
17
|
(()=>{
|
|
21
|
-
|
|
22
|
-
__webpack_require__.r = function(exports1) {
|
|
18
|
+
__webpack_require__.r = (exports1)=>{
|
|
23
19
|
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
24
20
|
value: 'Module'
|
|
25
21
|
});
|
|
@@ -28,13 +24,11 @@ var __webpack_require__ = {};
|
|
|
28
24
|
});
|
|
29
25
|
};
|
|
30
26
|
})();
|
|
31
|
-
|
|
32
|
-
// ESM COMPAT FLAG
|
|
27
|
+
var __webpack_exports__ = {};
|
|
33
28
|
__webpack_require__.r(__webpack_exports__);
|
|
34
|
-
// EXPORTS
|
|
35
29
|
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
-
PLUGIN_VUE2_NAME: ()
|
|
37
|
-
pluginVue2: ()
|
|
30
|
+
PLUGIN_VUE2_NAME: ()=>PLUGIN_VUE2_NAME,
|
|
31
|
+
pluginVue2: ()=>pluginVue2
|
|
38
32
|
});
|
|
39
33
|
const external_node_module_namespaceObject = require("node:module");
|
|
40
34
|
const external_vue_loader_namespaceObject = require("vue-loader");
|
|
@@ -48,24 +42,18 @@ function _define_property(obj, key, value) {
|
|
|
48
42
|
else obj[key] = value;
|
|
49
43
|
return obj;
|
|
50
44
|
}
|
|
51
|
-
|
|
52
|
-
* this plugin is a quick fix for issue https://github.com/web-infra-dev/rsbuild/issues/2093
|
|
53
|
-
*/ class VueLoader15PitchFixPlugin {
|
|
45
|
+
class VueLoader15PitchFixPlugin {
|
|
54
46
|
apply(compiler) {
|
|
55
47
|
const { NormalModule } = compiler.webpack;
|
|
56
48
|
compiler.hooks.compilation.tap(this.name, (compilation)=>{
|
|
57
49
|
var _compilation_compiler_options_experiments, _compilation_compiler_options;
|
|
58
50
|
const isExpCssOn = null === (_compilation_compiler_options = compilation.compiler.options) || void 0 === _compilation_compiler_options ? void 0 : null === (_compilation_compiler_options_experiments = _compilation_compiler_options.experiments) || void 0 === _compilation_compiler_options_experiments ? void 0 : _compilation_compiler_options_experiments.css;
|
|
59
|
-
// the related issue only happens when experiments.css is on
|
|
60
51
|
if (!isExpCssOn) return;
|
|
61
52
|
NormalModule.getCompilationHooks(compilation).loader.tap(this.name, (loaderContext)=>{
|
|
62
53
|
var _loaderContext_loaders_, _loaderContext_loaders;
|
|
63
|
-
if (/[?&]type=style/.test(loaderContext.resourceQuery) &&
|
|
64
|
-
// once `pitch` phase completed, vue-loader will remove its pitcher loader.
|
|
65
|
-
/[\\/]vue-loader[\\/]lib[\\/]loaders[\\/]pitcher/.test((null === (_loaderContext_loaders = loaderContext.loaders) || void 0 === _loaderContext_loaders ? void 0 : null === (_loaderContext_loaders_ = _loaderContext_loaders[0]) || void 0 === _loaderContext_loaders_ ? void 0 : _loaderContext_loaders_.path) || '')) {
|
|
54
|
+
if (/[?&]type=style/.test(loaderContext.resourceQuery) && /[\\/]vue-loader[\\/]lib[\\/]loaders[\\/]pitcher/.test((null === (_loaderContext_loaders = loaderContext.loaders) || void 0 === _loaderContext_loaders ? void 0 : null === (_loaderContext_loaders_ = _loaderContext_loaders[0]) || void 0 === _loaderContext_loaders_ ? void 0 : _loaderContext_loaders_.path) || '')) {
|
|
66
55
|
const seen = new Set();
|
|
67
56
|
const loaders = [];
|
|
68
|
-
// deduplicate loaders
|
|
69
57
|
for (const loader of loaderContext.loaders || []){
|
|
70
58
|
const identifier = 'string' == typeof loader ? loader : loader.path + loader.query;
|
|
71
59
|
if (!seen.has(identifier)) {
|
|
@@ -93,7 +81,7 @@ const applySplitChunksRule = (api, options = {
|
|
|
93
81
|
const currentConfig = chain.optimization.splitChunks.values();
|
|
94
82
|
if (!isPlainObject(currentConfig)) return;
|
|
95
83
|
const extraGroups = {};
|
|
96
|
-
if (options.
|
|
84
|
+
if (options.vue) extraGroups.vue = {
|
|
97
85
|
name: 'lib-vue',
|
|
98
86
|
test: /node_modules[\\/](?:vue|vue-loader)[\\/]/,
|
|
99
87
|
priority: 0
|
|
@@ -113,9 +101,7 @@ const applySplitChunksRule = (api, options = {
|
|
|
113
101
|
});
|
|
114
102
|
});
|
|
115
103
|
};
|
|
116
|
-
const src_require = (0, external_node_module_namespaceObject.createRequire)(
|
|
117
|
-
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;
|
|
118
|
-
}());
|
|
104
|
+
const src_require = (0, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__);
|
|
119
105
|
const PLUGIN_VUE2_NAME = 'rsbuild:vue2';
|
|
120
106
|
function pluginVue2(options = {}) {
|
|
121
107
|
return {
|
|
@@ -124,14 +110,12 @@ function pluginVue2(options = {}) {
|
|
|
124
110
|
const VUE_REGEXP = /\.vue$/;
|
|
125
111
|
const CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
|
|
126
112
|
api.modifyEnvironmentConfig((config, { mergeEnvironmentConfig })=>{
|
|
127
|
-
// Support `<style module>` in Vue SFC
|
|
128
113
|
if (true === config.output.cssModules.auto) config.output.cssModules.auto = (path, query)=>{
|
|
129
114
|
if (VUE_REGEXP.test(path)) return query.includes('type=style') && query.includes('module=true');
|
|
130
115
|
return CSS_MODULES_REGEX.test(path);
|
|
131
116
|
};
|
|
132
117
|
const extraConfig = {
|
|
133
118
|
source: {
|
|
134
|
-
// should transpile all scripts from Vue SFC
|
|
135
119
|
include: [
|
|
136
120
|
/\.vue/
|
|
137
121
|
]
|
|
@@ -141,11 +125,9 @@ function pluginVue2(options = {}) {
|
|
|
141
125
|
});
|
|
142
126
|
api.modifyBundlerChain((chain, { CHAIN_ID })=>{
|
|
143
127
|
chain.resolve.extensions.add('.vue');
|
|
144
|
-
// https://github.com/web-infra-dev/rsbuild/issues/1132
|
|
145
128
|
if (!chain.resolve.alias.get('vue$')) chain.resolve.alias.set('vue$', 'vue/dist/vue.runtime.esm.js');
|
|
146
129
|
const userLoaderOptions = options.vueLoaderOptions ?? {};
|
|
147
130
|
const compilerOptions = {
|
|
148
|
-
// https://github.com/vuejs/vue-cli/pull/3853
|
|
149
131
|
whitespace: 'condense',
|
|
150
132
|
...userLoaderOptions.compilerOptions
|
|
151
133
|
};
|
|
@@ -157,10 +139,8 @@ function pluginVue2(options = {}) {
|
|
|
157
139
|
const rule = chain.module.rule(CHAIN_ID.RULE.VUE);
|
|
158
140
|
rule.test(VUE_REGEXP).use(CHAIN_ID.USE.VUE).loader(src_require.resolve('vue-loader')).options(vueLoaderOptions);
|
|
159
141
|
if (chain.module.rules.has(CHAIN_ID.RULE.JS)) applyResolveConfig(rule, chain.module.rule(CHAIN_ID.RULE.JS));
|
|
160
|
-
// Support for lang="postcss" and lang="pcss" in SFC
|
|
161
142
|
chain.module.rule(CHAIN_ID.RULE.CSS).test(/\.(?:css|postcss|pcss)$/);
|
|
162
143
|
chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_PLUGIN).use(external_vue_loader_namespaceObject.VueLoaderPlugin);
|
|
163
|
-
// we could remove this once a new vue-loader@15 is released with https://github.com/vuejs/vue-loader/pull/2071 shipped
|
|
164
144
|
chain.plugin('vue-loader-15-pitch-fix').use(VueLoader15PitchFixPlugin);
|
|
165
145
|
});
|
|
166
146
|
applySplitChunksRule(api, options.splitChunks);
|
|
@@ -173,8 +153,12 @@ function applyResolveConfig(vueRule, jsRule) {
|
|
|
173
153
|
if (aliases) vueRule.resolve.alias.merge(aliases);
|
|
174
154
|
if (void 0 !== fullySpecified) vueRule.resolve.fullySpecified(fullySpecified);
|
|
175
155
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
156
|
+
exports.PLUGIN_VUE2_NAME = __webpack_exports__.PLUGIN_VUE2_NAME;
|
|
157
|
+
exports.pluginVue2 = __webpack_exports__.pluginVue2;
|
|
158
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
159
|
+
"PLUGIN_VUE2_NAME",
|
|
160
|
+
"pluginVue2"
|
|
161
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
162
|
+
Object.defineProperty(exports, '__esModule', {
|
|
179
163
|
value: true
|
|
180
164
|
});
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as
|
|
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
3
|
function _define_property(obj, key, value) {
|
|
4
4
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
5
5
|
value: value,
|
|
@@ -10,24 +10,18 @@ function _define_property(obj, key, value) {
|
|
|
10
10
|
else obj[key] = value;
|
|
11
11
|
return obj;
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
* this plugin is a quick fix for issue https://github.com/web-infra-dev/rsbuild/issues/2093
|
|
15
|
-
*/ class VueLoader15PitchFixPlugin {
|
|
13
|
+
class VueLoader15PitchFixPlugin {
|
|
16
14
|
apply(compiler) {
|
|
17
15
|
const { NormalModule } = compiler.webpack;
|
|
18
16
|
compiler.hooks.compilation.tap(this.name, (compilation)=>{
|
|
19
17
|
var _compilation_compiler_options_experiments, _compilation_compiler_options;
|
|
20
18
|
const isExpCssOn = null === (_compilation_compiler_options = compilation.compiler.options) || void 0 === _compilation_compiler_options ? void 0 : null === (_compilation_compiler_options_experiments = _compilation_compiler_options.experiments) || void 0 === _compilation_compiler_options_experiments ? void 0 : _compilation_compiler_options_experiments.css;
|
|
21
|
-
// the related issue only happens when experiments.css is on
|
|
22
19
|
if (!isExpCssOn) return;
|
|
23
20
|
NormalModule.getCompilationHooks(compilation).loader.tap(this.name, (loaderContext)=>{
|
|
24
21
|
var _loaderContext_loaders_, _loaderContext_loaders;
|
|
25
|
-
if (/[?&]type=style/.test(loaderContext.resourceQuery) &&
|
|
26
|
-
// once `pitch` phase completed, vue-loader will remove its pitcher loader.
|
|
27
|
-
/[\\/]vue-loader[\\/]lib[\\/]loaders[\\/]pitcher/.test((null === (_loaderContext_loaders = loaderContext.loaders) || void 0 === _loaderContext_loaders ? void 0 : null === (_loaderContext_loaders_ = _loaderContext_loaders[0]) || void 0 === _loaderContext_loaders_ ? void 0 : _loaderContext_loaders_.path) || '')) {
|
|
22
|
+
if (/[?&]type=style/.test(loaderContext.resourceQuery) && /[\\/]vue-loader[\\/]lib[\\/]loaders[\\/]pitcher/.test((null === (_loaderContext_loaders = loaderContext.loaders) || void 0 === _loaderContext_loaders ? void 0 : null === (_loaderContext_loaders_ = _loaderContext_loaders[0]) || void 0 === _loaderContext_loaders_ ? void 0 : _loaderContext_loaders_.path) || '')) {
|
|
28
23
|
const seen = new Set();
|
|
29
24
|
const loaders = [];
|
|
30
|
-
// deduplicate loaders
|
|
31
25
|
for (const loader of loaderContext.loaders || []){
|
|
32
26
|
const identifier = 'string' == typeof loader ? loader : loader.path + loader.query;
|
|
33
27
|
if (!seen.has(identifier)) {
|
|
@@ -55,7 +49,7 @@ const applySplitChunksRule = (api, options = {
|
|
|
55
49
|
const currentConfig = chain.optimization.splitChunks.values();
|
|
56
50
|
if (!isPlainObject(currentConfig)) return;
|
|
57
51
|
const extraGroups = {};
|
|
58
|
-
if (options.
|
|
52
|
+
if (options.vue) extraGroups.vue = {
|
|
59
53
|
name: 'lib-vue',
|
|
60
54
|
test: /node_modules[\\/](?:vue|vue-loader)[\\/]/,
|
|
61
55
|
priority: 0
|
|
@@ -75,7 +69,7 @@ const applySplitChunksRule = (api, options = {
|
|
|
75
69
|
});
|
|
76
70
|
});
|
|
77
71
|
};
|
|
78
|
-
const src_require = (0,
|
|
72
|
+
const src_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__.createRequire)(import.meta.url);
|
|
79
73
|
const PLUGIN_VUE2_NAME = 'rsbuild:vue2';
|
|
80
74
|
function pluginVue2(options = {}) {
|
|
81
75
|
return {
|
|
@@ -84,14 +78,12 @@ function pluginVue2(options = {}) {
|
|
|
84
78
|
const VUE_REGEXP = /\.vue$/;
|
|
85
79
|
const CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
|
|
86
80
|
api.modifyEnvironmentConfig((config, { mergeEnvironmentConfig })=>{
|
|
87
|
-
// Support `<style module>` in Vue SFC
|
|
88
81
|
if (true === config.output.cssModules.auto) config.output.cssModules.auto = (path, query)=>{
|
|
89
82
|
if (VUE_REGEXP.test(path)) return query.includes('type=style') && query.includes('module=true');
|
|
90
83
|
return CSS_MODULES_REGEX.test(path);
|
|
91
84
|
};
|
|
92
85
|
const extraConfig = {
|
|
93
86
|
source: {
|
|
94
|
-
// should transpile all scripts from Vue SFC
|
|
95
87
|
include: [
|
|
96
88
|
/\.vue/
|
|
97
89
|
]
|
|
@@ -101,11 +93,9 @@ function pluginVue2(options = {}) {
|
|
|
101
93
|
});
|
|
102
94
|
api.modifyBundlerChain((chain, { CHAIN_ID })=>{
|
|
103
95
|
chain.resolve.extensions.add('.vue');
|
|
104
|
-
// https://github.com/web-infra-dev/rsbuild/issues/1132
|
|
105
96
|
if (!chain.resolve.alias.get('vue$')) chain.resolve.alias.set('vue$', 'vue/dist/vue.runtime.esm.js');
|
|
106
97
|
const userLoaderOptions = options.vueLoaderOptions ?? {};
|
|
107
98
|
const compilerOptions = {
|
|
108
|
-
// https://github.com/vuejs/vue-cli/pull/3853
|
|
109
99
|
whitespace: 'condense',
|
|
110
100
|
...userLoaderOptions.compilerOptions
|
|
111
101
|
};
|
|
@@ -117,10 +107,8 @@ function pluginVue2(options = {}) {
|
|
|
117
107
|
const rule = chain.module.rule(CHAIN_ID.RULE.VUE);
|
|
118
108
|
rule.test(VUE_REGEXP).use(CHAIN_ID.USE.VUE).loader(src_require.resolve('vue-loader')).options(vueLoaderOptions);
|
|
119
109
|
if (chain.module.rules.has(CHAIN_ID.RULE.JS)) applyResolveConfig(rule, chain.module.rule(CHAIN_ID.RULE.JS));
|
|
120
|
-
// Support for lang="postcss" and lang="pcss" in SFC
|
|
121
110
|
chain.module.rule(CHAIN_ID.RULE.CSS).test(/\.(?:css|postcss|pcss)$/);
|
|
122
|
-
chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_PLUGIN).use(
|
|
123
|
-
// we could remove this once a new vue-loader@15 is released with https://github.com/vuejs/vue-loader/pull/2071 shipped
|
|
111
|
+
chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_PLUGIN).use(__WEBPACK_EXTERNAL_MODULE_vue_loader_a33e643c__.VueLoaderPlugin);
|
|
124
112
|
chain.plugin('vue-loader-15-pitch-fix').use(VueLoader15PitchFixPlugin);
|
|
125
113
|
});
|
|
126
114
|
applySplitChunksRule(api, options.splitChunks);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-vue2",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"repository": "https://github.com/rspack-contrib/rsbuild-plugin-vue2",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -36,20 +36,19 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"vue-loader": "^15.11.1",
|
|
39
|
-
"webpack": "^5.
|
|
39
|
+
"webpack": "^5.98.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@biomejs/biome": "^1.9.4",
|
|
43
|
-
"@playwright/test": "^1.
|
|
44
|
-
"@rsbuild/core": "^1.1
|
|
45
|
-
"@rsbuild/plugin-less": "1.1
|
|
46
|
-
"@rslib/core": "^0.
|
|
47
|
-
"@types/node": "^
|
|
43
|
+
"@playwright/test": "^1.51.1",
|
|
44
|
+
"@rsbuild/core": "^1.3.1",
|
|
45
|
+
"@rsbuild/plugin-less": "1.2.1",
|
|
46
|
+
"@rslib/core": "^0.6.1",
|
|
47
|
+
"@types/node": "^22.13.14",
|
|
48
48
|
"nano-staged": "^0.8.0",
|
|
49
|
-
"playwright": "^1.
|
|
50
|
-
"simple-git-hooks": "^2.
|
|
51
|
-
"
|
|
52
|
-
"typescript": "^5.6.3",
|
|
49
|
+
"playwright": "^1.51.1",
|
|
50
|
+
"simple-git-hooks": "^2.12.1",
|
|
51
|
+
"typescript": "^5.8.2",
|
|
53
52
|
"vue": "^2.7.16"
|
|
54
53
|
},
|
|
55
54
|
"peerDependencies": {
|
|
@@ -60,7 +59,7 @@
|
|
|
60
59
|
"optional": true
|
|
61
60
|
}
|
|
62
61
|
},
|
|
63
|
-
"packageManager": "pnpm@
|
|
62
|
+
"packageManager": "pnpm@10.7.0",
|
|
64
63
|
"publishConfig": {
|
|
65
64
|
"access": "public",
|
|
66
65
|
"registry": "https://registry.npmjs.org/",
|