@rsbuild/plugin-vue2 0.0.0-next-20240513013836 → 0.0.0-next-20240528072128
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.mjs → index.cjs} +68 -35
- package/dist/index.js +49 -51
- package/package.json +9 -9
|
@@ -1,27 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
4
3
|
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
8
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
13
30
|
var __publicField = (obj, key, value) => {
|
|
14
31
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
15
32
|
return value;
|
|
16
33
|
};
|
|
17
34
|
|
|
18
|
-
// ../../node_modules/.pnpm/@modern-js+module-tools@2.49.2_eslint@8.57.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js
|
|
19
|
-
import { fileURLToPath } from "url";
|
|
20
|
-
import path from "path";
|
|
21
|
-
|
|
22
35
|
// src/index.ts
|
|
23
|
-
|
|
24
|
-
|
|
36
|
+
var src_exports = {};
|
|
37
|
+
__export(src_exports, {
|
|
38
|
+
pluginVue2: () => pluginVue2
|
|
39
|
+
});
|
|
40
|
+
module.exports = __toCommonJS(src_exports);
|
|
41
|
+
var import_vue_loader = require("vue-loader");
|
|
25
42
|
|
|
26
43
|
// src/VueLoader15PitchFixPlugin.ts
|
|
27
44
|
var VueLoader15PitchFixPlugin = class {
|
|
@@ -63,10 +80,7 @@ var VueLoader15PitchFixPlugin = class {
|
|
|
63
80
|
};
|
|
64
81
|
|
|
65
82
|
// src/splitChunks.ts
|
|
66
|
-
|
|
67
|
-
createCacheGroups,
|
|
68
|
-
isPlainObject
|
|
69
|
-
} from "@rsbuild/shared";
|
|
83
|
+
var import_shared = require("@rsbuild/shared");
|
|
70
84
|
var applySplitChunksRule = (api, options = {
|
|
71
85
|
vue: true,
|
|
72
86
|
router: true
|
|
@@ -77,7 +91,7 @@ var applySplitChunksRule = (api, options = {
|
|
|
77
91
|
return;
|
|
78
92
|
}
|
|
79
93
|
const currentConfig = chain.optimization.splitChunks.values();
|
|
80
|
-
if (!isPlainObject(currentConfig)) {
|
|
94
|
+
if (!(0, import_shared.isPlainObject)(currentConfig)) {
|
|
81
95
|
return;
|
|
82
96
|
}
|
|
83
97
|
const extraGroups = {};
|
|
@@ -95,7 +109,7 @@ var applySplitChunksRule = (api, options = {
|
|
|
95
109
|
// @ts-expect-error Rspack and Webpack uses different cacheGroups type
|
|
96
110
|
cacheGroups: {
|
|
97
111
|
...currentConfig.cacheGroups,
|
|
98
|
-
...createCacheGroups(extraGroups)
|
|
112
|
+
...(0, import_shared.createCacheGroups)(extraGroups)
|
|
99
113
|
}
|
|
100
114
|
});
|
|
101
115
|
});
|
|
@@ -106,28 +120,47 @@ function pluginVue2(options = {}) {
|
|
|
106
120
|
return {
|
|
107
121
|
name: "rsbuild:vue2",
|
|
108
122
|
setup(api) {
|
|
123
|
+
const VUE_REGEXP = /\.vue$/;
|
|
124
|
+
const CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
|
|
125
|
+
api.modifyRsbuildConfig((config) => {
|
|
126
|
+
var _a;
|
|
127
|
+
config.output || (config.output = {});
|
|
128
|
+
(_a = config.output).cssModules || (_a.cssModules = {});
|
|
129
|
+
if (config.output.cssModules.auto === true) {
|
|
130
|
+
config.output.cssModules.auto = (path, query) => {
|
|
131
|
+
if (VUE_REGEXP.test(path)) {
|
|
132
|
+
return query.includes("type=style") && query.includes("module=true");
|
|
133
|
+
}
|
|
134
|
+
return CSS_MODULES_REGEX.test(path);
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
return config;
|
|
138
|
+
});
|
|
109
139
|
api.modifyBundlerChain((chain, { CHAIN_ID }) => {
|
|
110
140
|
chain.resolve.extensions.add(".vue");
|
|
111
141
|
if (!chain.resolve.alias.get("vue$")) {
|
|
112
142
|
chain.resolve.alias.set("vue$", "vue/dist/vue.runtime.esm.js");
|
|
113
143
|
}
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
chain.
|
|
144
|
+
const userLoaderOptions = options.vueLoaderOptions ?? {};
|
|
145
|
+
const compilerOptions = {
|
|
146
|
+
preserveWhitespace: false,
|
|
147
|
+
...userLoaderOptions.compilerOptions
|
|
148
|
+
};
|
|
149
|
+
const vueLoaderOptions = {
|
|
150
|
+
experimentalInlineMatchResource: true,
|
|
151
|
+
...userLoaderOptions,
|
|
152
|
+
compilerOptions
|
|
153
|
+
};
|
|
154
|
+
chain.module.rule(CHAIN_ID.RULE.VUE).test(VUE_REGEXP).use(CHAIN_ID.USE.VUE).loader(require.resolve("vue-loader")).options(vueLoaderOptions);
|
|
155
|
+
chain.module.rule(CHAIN_ID.RULE.CSS).test(/\.(?:css|postcss|pcss)$/);
|
|
156
|
+
chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_PLUGIN).use(import_vue_loader.VueLoaderPlugin);
|
|
125
157
|
chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_15_PITCH_FIX_PLUGIN).use(VueLoader15PitchFixPlugin);
|
|
126
158
|
});
|
|
127
159
|
applySplitChunksRule(api, options.splitChunks);
|
|
128
160
|
}
|
|
129
161
|
};
|
|
130
162
|
}
|
|
131
|
-
export
|
|
163
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
164
|
+
0 && (module.exports = {
|
|
132
165
|
pluginVue2
|
|
133
|
-
};
|
|
166
|
+
});
|
package/dist/index.js
CHANGED
|
@@ -1,45 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
1
|
+
import { createRequire } from 'module';
|
|
2
|
+
var require = createRequire(import.meta['url']);
|
|
3
|
+
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
5
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
-
}
|
|
19
|
-
return to;
|
|
20
|
-
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
6
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
7
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
8
|
+
}) : x)(function(x) {
|
|
9
|
+
if (typeof require !== "undefined")
|
|
10
|
+
return require.apply(this, arguments);
|
|
11
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
12
|
+
});
|
|
30
13
|
var __publicField = (obj, key, value) => {
|
|
31
14
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
32
15
|
return value;
|
|
33
16
|
};
|
|
34
17
|
|
|
18
|
+
// ../../node_modules/.pnpm/@modern-js+module-tools@2.50.0_eslint@9.3.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js
|
|
19
|
+
import { fileURLToPath } from "url";
|
|
20
|
+
import path from "path";
|
|
21
|
+
|
|
35
22
|
// src/index.ts
|
|
36
|
-
|
|
37
|
-
__export(src_exports, {
|
|
38
|
-
pluginVue2: () => pluginVue2
|
|
39
|
-
});
|
|
40
|
-
module.exports = __toCommonJS(src_exports);
|
|
41
|
-
var import_shared2 = require("@rsbuild/shared");
|
|
42
|
-
var import_vue_loader = require("vue-loader");
|
|
23
|
+
import { VueLoaderPlugin } from "vue-loader";
|
|
43
24
|
|
|
44
25
|
// src/VueLoader15PitchFixPlugin.ts
|
|
45
26
|
var VueLoader15PitchFixPlugin = class {
|
|
@@ -81,7 +62,7 @@ var VueLoader15PitchFixPlugin = class {
|
|
|
81
62
|
};
|
|
82
63
|
|
|
83
64
|
// src/splitChunks.ts
|
|
84
|
-
|
|
65
|
+
import { createCacheGroups, isPlainObject } from "@rsbuild/shared";
|
|
85
66
|
var applySplitChunksRule = (api, options = {
|
|
86
67
|
vue: true,
|
|
87
68
|
router: true
|
|
@@ -92,7 +73,7 @@ var applySplitChunksRule = (api, options = {
|
|
|
92
73
|
return;
|
|
93
74
|
}
|
|
94
75
|
const currentConfig = chain.optimization.splitChunks.values();
|
|
95
|
-
if (!
|
|
76
|
+
if (!isPlainObject(currentConfig)) {
|
|
96
77
|
return;
|
|
97
78
|
}
|
|
98
79
|
const extraGroups = {};
|
|
@@ -110,7 +91,7 @@ var applySplitChunksRule = (api, options = {
|
|
|
110
91
|
// @ts-expect-error Rspack and Webpack uses different cacheGroups type
|
|
111
92
|
cacheGroups: {
|
|
112
93
|
...currentConfig.cacheGroups,
|
|
113
|
-
...
|
|
94
|
+
...createCacheGroups(extraGroups)
|
|
114
95
|
}
|
|
115
96
|
});
|
|
116
97
|
});
|
|
@@ -121,29 +102,46 @@ function pluginVue2(options = {}) {
|
|
|
121
102
|
return {
|
|
122
103
|
name: "rsbuild:vue2",
|
|
123
104
|
setup(api) {
|
|
105
|
+
const VUE_REGEXP = /\.vue$/;
|
|
106
|
+
const CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
|
|
107
|
+
api.modifyRsbuildConfig((config) => {
|
|
108
|
+
var _a;
|
|
109
|
+
config.output || (config.output = {});
|
|
110
|
+
(_a = config.output).cssModules || (_a.cssModules = {});
|
|
111
|
+
if (config.output.cssModules.auto === true) {
|
|
112
|
+
config.output.cssModules.auto = (path2, query) => {
|
|
113
|
+
if (VUE_REGEXP.test(path2)) {
|
|
114
|
+
return query.includes("type=style") && query.includes("module=true");
|
|
115
|
+
}
|
|
116
|
+
return CSS_MODULES_REGEX.test(path2);
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
return config;
|
|
120
|
+
});
|
|
124
121
|
api.modifyBundlerChain((chain, { CHAIN_ID }) => {
|
|
125
122
|
chain.resolve.extensions.add(".vue");
|
|
126
123
|
if (!chain.resolve.alias.get("vue$")) {
|
|
127
124
|
chain.resolve.alias.set("vue$", "vue/dist/vue.runtime.esm.js");
|
|
128
125
|
}
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
chain.
|
|
126
|
+
const userLoaderOptions = options.vueLoaderOptions ?? {};
|
|
127
|
+
const compilerOptions = {
|
|
128
|
+
preserveWhitespace: false,
|
|
129
|
+
...userLoaderOptions.compilerOptions
|
|
130
|
+
};
|
|
131
|
+
const vueLoaderOptions = {
|
|
132
|
+
experimentalInlineMatchResource: true,
|
|
133
|
+
...userLoaderOptions,
|
|
134
|
+
compilerOptions
|
|
135
|
+
};
|
|
136
|
+
chain.module.rule(CHAIN_ID.RULE.VUE).test(VUE_REGEXP).use(CHAIN_ID.USE.VUE).loader(__require.resolve("vue-loader")).options(vueLoaderOptions);
|
|
137
|
+
chain.module.rule(CHAIN_ID.RULE.CSS).test(/\.(?:css|postcss|pcss)$/);
|
|
138
|
+
chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_PLUGIN).use(VueLoaderPlugin);
|
|
140
139
|
chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_15_PITCH_FIX_PLUGIN).use(VueLoader15PitchFixPlugin);
|
|
141
140
|
});
|
|
142
141
|
applySplitChunksRule(api, options.splitChunks);
|
|
143
142
|
}
|
|
144
143
|
};
|
|
145
144
|
}
|
|
146
|
-
|
|
147
|
-
0 && (module.exports = {
|
|
145
|
+
export {
|
|
148
146
|
pluginVue2
|
|
149
|
-
}
|
|
147
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-vue2",
|
|
3
|
-
"version": "0.0.0-next-
|
|
3
|
+
"version": "0.0.0-next-20240528072128",
|
|
4
4
|
"description": "Vue 2 plugin of Rsbuild",
|
|
5
5
|
"homepage": "https://rsbuild.dev",
|
|
6
6
|
"repository": {
|
|
@@ -9,15 +9,15 @@
|
|
|
9
9
|
"directory": "packages/plugin-vue2"
|
|
10
10
|
},
|
|
11
11
|
"license": "MIT",
|
|
12
|
-
"type": "
|
|
12
|
+
"type": "module",
|
|
13
13
|
"exports": {
|
|
14
14
|
".": {
|
|
15
15
|
"types": "./dist/index.d.ts",
|
|
16
|
-
"import": "./dist/index.
|
|
17
|
-
"
|
|
16
|
+
"import": "./dist/index.js",
|
|
17
|
+
"require": "./dist/index.cjs"
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
|
-
"main": "./dist/index.
|
|
20
|
+
"main": "./dist/index.cjs",
|
|
21
21
|
"types": "./dist/index.d.ts",
|
|
22
22
|
"files": [
|
|
23
23
|
"dist"
|
|
@@ -25,16 +25,16 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"vue-loader": "^15.11.1",
|
|
27
27
|
"webpack": "^5.91.0",
|
|
28
|
-
"@rsbuild/shared": "0.0.0-next-
|
|
28
|
+
"@rsbuild/shared": "0.0.0-next-20240528072128"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"typescript": "^5.4.2",
|
|
32
32
|
"webpack": "^5.91.0",
|
|
33
|
-
"@
|
|
34
|
-
"@
|
|
33
|
+
"@rsbuild/core": "0.0.0-next-20240528072128",
|
|
34
|
+
"@scripts/test-helper": "0.0.0-next-20240528072128"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@rsbuild/core": "0.0.0-next-
|
|
37
|
+
"@rsbuild/core": "0.0.0-next-20240528072128"
|
|
38
38
|
},
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public",
|