@rsbuild/plugin-vue2 1.0.0 → 1.0.1-beta.1
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/README.md +1 -1
- package/dist/VueLoader15PitchFixPlugin.d.ts +8 -0
- package/dist/index.cjs +190 -0
- package/dist/index.d.ts +25 -7
- package/dist/index.js +154 -47
- package/dist/splitChunks.d.ts +3 -0
- package/package.json +11 -11
- package/dist/index.mjs +0 -43
package/README.md
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Rspack } from '@rsbuild/core';
|
|
2
|
+
/**
|
|
3
|
+
* this plugin is a quick fix for issue https://github.com/web-infra-dev/rsbuild/issues/2093
|
|
4
|
+
*/
|
|
5
|
+
export declare class VueLoader15PitchFixPlugin implements Rspack.RspackPluginInstance {
|
|
6
|
+
readonly name = "VueLoader15PitchFixPlugin";
|
|
7
|
+
apply(compiler: Rspack.Compiler): void;
|
|
8
|
+
}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
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;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
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);
|
|
30
|
+
var __publicField = (obj, key, value) => {
|
|
31
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
32
|
+
return value;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// src/index.ts
|
|
36
|
+
var src_exports = {};
|
|
37
|
+
__export(src_exports, {
|
|
38
|
+
PLUGIN_VUE2_NAME: () => PLUGIN_VUE2_NAME,
|
|
39
|
+
pluginVue2: () => pluginVue2
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(src_exports);
|
|
42
|
+
var import_vue_loader = require("vue-loader");
|
|
43
|
+
|
|
44
|
+
// src/VueLoader15PitchFixPlugin.ts
|
|
45
|
+
var VueLoader15PitchFixPlugin = class {
|
|
46
|
+
constructor() {
|
|
47
|
+
__publicField(this, "name", "VueLoader15PitchFixPlugin");
|
|
48
|
+
}
|
|
49
|
+
apply(compiler) {
|
|
50
|
+
const { NormalModule } = compiler.webpack;
|
|
51
|
+
compiler.hooks.compilation.tap(this.name, (compilation) => {
|
|
52
|
+
const isExpCssOn = compilation.compiler.options?.experiments?.css;
|
|
53
|
+
if (!isExpCssOn)
|
|
54
|
+
return;
|
|
55
|
+
NormalModule.getCompilationHooks(compilation).loader.tap(
|
|
56
|
+
this.name,
|
|
57
|
+
(loaderContext) => {
|
|
58
|
+
if (
|
|
59
|
+
// the related issue only happens for <style>
|
|
60
|
+
/[?&]type=style/.test(loaderContext.resourceQuery) && // the fix should be applied before `pitch` phase completed.
|
|
61
|
+
// once `pitch` phase completed, vue-loader will remove its pitcher loader.
|
|
62
|
+
/[\\/]vue-loader[\\/]lib[\\/]loaders[\\/]pitcher/.test(
|
|
63
|
+
loaderContext.loaders?.[0]?.path || ""
|
|
64
|
+
)
|
|
65
|
+
) {
|
|
66
|
+
const seen = /* @__PURE__ */ new Set();
|
|
67
|
+
const loaders = [];
|
|
68
|
+
for (const loader of loaderContext.loaders || []) {
|
|
69
|
+
const identifier = typeof loader === "string" ? loader : loader.path + loader.query;
|
|
70
|
+
if (!seen.has(identifier)) {
|
|
71
|
+
seen.add(identifier);
|
|
72
|
+
loaders.push(loader);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
loaderContext.loaders = loaders;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
// src/splitChunks.ts
|
|
84
|
+
var isPlainObject = (obj) => obj !== null && typeof obj === "object" && Object.prototype.toString.call(obj) === "[object Object]";
|
|
85
|
+
var applySplitChunksRule = (api, options = {
|
|
86
|
+
vue: true,
|
|
87
|
+
router: true
|
|
88
|
+
}) => {
|
|
89
|
+
api.modifyBundlerChain((chain, { environment }) => {
|
|
90
|
+
const { config } = environment;
|
|
91
|
+
if (config.performance.chunkSplit.strategy !== "split-by-experience") {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const currentConfig = chain.optimization.splitChunks.values();
|
|
95
|
+
if (!isPlainObject(currentConfig)) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const extraGroups = {};
|
|
99
|
+
if (options.router) {
|
|
100
|
+
extraGroups.vue = {
|
|
101
|
+
name: "lib-vue",
|
|
102
|
+
test: /node_modules[\\/](?:vue|vue-loader)[\\/]/,
|
|
103
|
+
priority: 0
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
if (options.router) {
|
|
107
|
+
extraGroups.router = {
|
|
108
|
+
name: "lib-router",
|
|
109
|
+
test: /node_modules[\\/]vue-router[\\/]/,
|
|
110
|
+
priority: 0
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
if (!Object.keys(extraGroups).length) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
chain.optimization.splitChunks({
|
|
117
|
+
...currentConfig,
|
|
118
|
+
cacheGroups: {
|
|
119
|
+
...currentConfig.cacheGroups,
|
|
120
|
+
...extraGroups
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
// src/index.ts
|
|
127
|
+
var PLUGIN_VUE2_NAME = "rsbuild:vue2";
|
|
128
|
+
function pluginVue2(options = {}) {
|
|
129
|
+
return {
|
|
130
|
+
name: PLUGIN_VUE2_NAME,
|
|
131
|
+
setup(api) {
|
|
132
|
+
const VUE_REGEXP = /\.vue$/;
|
|
133
|
+
const CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
|
|
134
|
+
api.modifyRsbuildConfig((config) => {
|
|
135
|
+
config.output ||= {};
|
|
136
|
+
config.output.cssModules ||= {};
|
|
137
|
+
if (config.output.cssModules.auto === true) {
|
|
138
|
+
config.output.cssModules.auto = (path, query) => {
|
|
139
|
+
if (VUE_REGEXP.test(path)) {
|
|
140
|
+
return query.includes("type=style") && query.includes("module=true");
|
|
141
|
+
}
|
|
142
|
+
return CSS_MODULES_REGEX.test(path);
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
return config;
|
|
146
|
+
});
|
|
147
|
+
api.modifyBundlerChain((chain, { CHAIN_ID }) => {
|
|
148
|
+
chain.resolve.extensions.add(".vue");
|
|
149
|
+
if (!chain.resolve.alias.get("vue$")) {
|
|
150
|
+
chain.resolve.alias.set("vue$", "vue/dist/vue.runtime.esm.js");
|
|
151
|
+
}
|
|
152
|
+
const userLoaderOptions = options.vueLoaderOptions ?? {};
|
|
153
|
+
const compilerOptions = {
|
|
154
|
+
// https://github.com/vuejs/vue-cli/pull/3853
|
|
155
|
+
whitespace: "condense",
|
|
156
|
+
...userLoaderOptions.compilerOptions
|
|
157
|
+
};
|
|
158
|
+
const vueLoaderOptions = {
|
|
159
|
+
experimentalInlineMatchResource: true,
|
|
160
|
+
...userLoaderOptions,
|
|
161
|
+
compilerOptions
|
|
162
|
+
};
|
|
163
|
+
const rule = chain.module.rule(CHAIN_ID.RULE.VUE);
|
|
164
|
+
rule.test(VUE_REGEXP).use(CHAIN_ID.USE.VUE).loader(require.resolve("vue-loader")).options(vueLoaderOptions);
|
|
165
|
+
if (chain.module.rules.has(CHAIN_ID.RULE.JS)) {
|
|
166
|
+
applyResolveConfig(rule, chain.module.rule(CHAIN_ID.RULE.JS));
|
|
167
|
+
}
|
|
168
|
+
chain.module.rule(CHAIN_ID.RULE.CSS).test(/\.(?:css|postcss|pcss)$/);
|
|
169
|
+
chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_PLUGIN).use(import_vue_loader.VueLoaderPlugin);
|
|
170
|
+
chain.plugin("vue-loader-15-pitch-fix").use(VueLoader15PitchFixPlugin);
|
|
171
|
+
});
|
|
172
|
+
applySplitChunksRule(api, options.splitChunks);
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
function applyResolveConfig(vueRule, jsRule) {
|
|
177
|
+
const fullySpecified = jsRule.resolve.get("fullySpecified");
|
|
178
|
+
const aliases = jsRule.resolve.alias.entries();
|
|
179
|
+
if (aliases) {
|
|
180
|
+
vueRule.resolve.alias.merge(aliases);
|
|
181
|
+
}
|
|
182
|
+
if (fullySpecified !== void 0) {
|
|
183
|
+
vueRule.resolve.fullySpecified(fullySpecified);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
187
|
+
0 && (module.exports = {
|
|
188
|
+
PLUGIN_VUE2_NAME,
|
|
189
|
+
pluginVue2
|
|
190
|
+
});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,27 @@
|
|
|
1
|
-
import { RsbuildPlugin } from '@rsbuild/core';
|
|
2
|
-
import { VueLoaderOptions } from 'vue-loader';
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type { RsbuildPlugin } from '@rsbuild/core';
|
|
2
|
+
import { type VueLoaderOptions } from 'vue-loader';
|
|
3
|
+
export type SplitVueChunkOptions = {
|
|
4
|
+
/**
|
|
5
|
+
* Whether to enable split chunking for Vue-related dependencies (e.g., vue, vue-loader).
|
|
6
|
+
* @default true
|
|
7
|
+
*/
|
|
8
|
+
vue?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Whether to enable split chunking for vue-router.
|
|
11
|
+
* @default true
|
|
12
|
+
*/
|
|
13
|
+
router?: boolean;
|
|
14
|
+
};
|
|
15
|
+
export type PluginVueOptions = {
|
|
16
|
+
/**
|
|
17
|
+
* Options passed to `vue-loader`.
|
|
18
|
+
* @see https://vue-loader.vuejs.org/
|
|
19
|
+
*/
|
|
5
20
|
vueLoaderOptions?: VueLoaderOptions;
|
|
21
|
+
/**
|
|
22
|
+
* This option is used to control the split chunks behavior.
|
|
23
|
+
*/
|
|
24
|
+
splitChunks?: SplitVueChunkOptions;
|
|
6
25
|
};
|
|
7
|
-
declare
|
|
8
|
-
|
|
9
|
-
export { PluginVueOptions, pluginVue2 };
|
|
26
|
+
export declare const PLUGIN_VUE2_NAME = "rsbuild:vue2";
|
|
27
|
+
export declare function pluginVue2(options?: PluginVueOptions): RsbuildPlugin;
|
package/dist/index.js
CHANGED
|
@@ -1,63 +1,170 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
1
|
+
import { createRequire } from 'module';
|
|
2
|
+
var require = createRequire(import.meta['url']);
|
|
3
|
+
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
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
|
+
});
|
|
13
|
+
var __publicField = (obj, key, value) => {
|
|
14
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
15
|
+
return value;
|
|
11
16
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
|
|
18
|
+
// ../../node_modules/.pnpm/@modern-js+module-tools@2.55.0_eslint@9.6.0_typescript@5.5.2/node_modules/@modern-js/module-tools/shims/esm.js
|
|
19
|
+
import { fileURLToPath } from "url";
|
|
20
|
+
import path from "path";
|
|
21
|
+
|
|
22
|
+
// src/index.ts
|
|
23
|
+
import { VueLoaderPlugin } from "vue-loader";
|
|
24
|
+
|
|
25
|
+
// src/VueLoader15PitchFixPlugin.ts
|
|
26
|
+
var VueLoader15PitchFixPlugin = class {
|
|
27
|
+
constructor() {
|
|
28
|
+
__publicField(this, "name", "VueLoader15PitchFixPlugin");
|
|
29
|
+
}
|
|
30
|
+
apply(compiler) {
|
|
31
|
+
const { NormalModule } = compiler.webpack;
|
|
32
|
+
compiler.hooks.compilation.tap(this.name, (compilation) => {
|
|
33
|
+
const isExpCssOn = compilation.compiler.options?.experiments?.css;
|
|
34
|
+
if (!isExpCssOn)
|
|
35
|
+
return;
|
|
36
|
+
NormalModule.getCompilationHooks(compilation).loader.tap(
|
|
37
|
+
this.name,
|
|
38
|
+
(loaderContext) => {
|
|
39
|
+
if (
|
|
40
|
+
// the related issue only happens for <style>
|
|
41
|
+
/[?&]type=style/.test(loaderContext.resourceQuery) && // the fix should be applied before `pitch` phase completed.
|
|
42
|
+
// once `pitch` phase completed, vue-loader will remove its pitcher loader.
|
|
43
|
+
/[\\/]vue-loader[\\/]lib[\\/]loaders[\\/]pitcher/.test(
|
|
44
|
+
loaderContext.loaders?.[0]?.path || ""
|
|
45
|
+
)
|
|
46
|
+
) {
|
|
47
|
+
const seen = /* @__PURE__ */ new Set();
|
|
48
|
+
const loaders = [];
|
|
49
|
+
for (const loader of loaderContext.loaders || []) {
|
|
50
|
+
const identifier = typeof loader === "string" ? loader : loader.path + loader.query;
|
|
51
|
+
if (!seen.has(identifier)) {
|
|
52
|
+
seen.add(identifier);
|
|
53
|
+
loaders.push(loader);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
loaderContext.loaders = loaders;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
});
|
|
17
61
|
}
|
|
18
|
-
return to;
|
|
19
62
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
)
|
|
28
|
-
|
|
63
|
+
|
|
64
|
+
// src/splitChunks.ts
|
|
65
|
+
var isPlainObject = (obj) => obj !== null && typeof obj === "object" && Object.prototype.toString.call(obj) === "[object Object]";
|
|
66
|
+
var applySplitChunksRule = (api, options = {
|
|
67
|
+
vue: true,
|
|
68
|
+
router: true
|
|
69
|
+
}) => {
|
|
70
|
+
api.modifyBundlerChain((chain, { environment }) => {
|
|
71
|
+
const { config } = environment;
|
|
72
|
+
if (config.performance.chunkSplit.strategy !== "split-by-experience") {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const currentConfig = chain.optimization.splitChunks.values();
|
|
76
|
+
if (!isPlainObject(currentConfig)) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const extraGroups = {};
|
|
80
|
+
if (options.router) {
|
|
81
|
+
extraGroups.vue = {
|
|
82
|
+
name: "lib-vue",
|
|
83
|
+
test: /node_modules[\\/](?:vue|vue-loader)[\\/]/,
|
|
84
|
+
priority: 0
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
if (options.router) {
|
|
88
|
+
extraGroups.router = {
|
|
89
|
+
name: "lib-router",
|
|
90
|
+
test: /node_modules[\\/]vue-router[\\/]/,
|
|
91
|
+
priority: 0
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
if (!Object.keys(extraGroups).length) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
chain.optimization.splitChunks({
|
|
98
|
+
...currentConfig,
|
|
99
|
+
cacheGroups: {
|
|
100
|
+
...currentConfig.cacheGroups,
|
|
101
|
+
...extraGroups
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
};
|
|
29
106
|
|
|
30
107
|
// src/index.ts
|
|
31
|
-
var
|
|
32
|
-
__export(src_exports, {
|
|
33
|
-
pluginVue2: () => pluginVue2
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(src_exports);
|
|
36
|
-
var import_shared = require("@rsbuild/shared");
|
|
37
|
-
var import_vue_loader = require("vue-loader");
|
|
108
|
+
var PLUGIN_VUE2_NAME = "rsbuild:vue2";
|
|
38
109
|
function pluginVue2(options = {}) {
|
|
39
110
|
return {
|
|
40
|
-
name:
|
|
111
|
+
name: PLUGIN_VUE2_NAME,
|
|
41
112
|
setup(api) {
|
|
113
|
+
const VUE_REGEXP = /\.vue$/;
|
|
114
|
+
const CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
|
|
115
|
+
api.modifyRsbuildConfig((config) => {
|
|
116
|
+
config.output ||= {};
|
|
117
|
+
config.output.cssModules ||= {};
|
|
118
|
+
if (config.output.cssModules.auto === true) {
|
|
119
|
+
config.output.cssModules.auto = (path2, query) => {
|
|
120
|
+
if (VUE_REGEXP.test(path2)) {
|
|
121
|
+
return query.includes("type=style") && query.includes("module=true");
|
|
122
|
+
}
|
|
123
|
+
return CSS_MODULES_REGEX.test(path2);
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
return config;
|
|
127
|
+
});
|
|
42
128
|
api.modifyBundlerChain((chain, { CHAIN_ID }) => {
|
|
43
|
-
var _a;
|
|
44
129
|
chain.resolve.extensions.add(".vue");
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
130
|
+
if (!chain.resolve.alias.get("vue$")) {
|
|
131
|
+
chain.resolve.alias.set("vue$", "vue/dist/vue.runtime.esm.js");
|
|
132
|
+
}
|
|
133
|
+
const userLoaderOptions = options.vueLoaderOptions ?? {};
|
|
134
|
+
const compilerOptions = {
|
|
135
|
+
// https://github.com/vuejs/vue-cli/pull/3853
|
|
136
|
+
whitespace: "condense",
|
|
137
|
+
...userLoaderOptions.compilerOptions
|
|
138
|
+
};
|
|
139
|
+
const vueLoaderOptions = {
|
|
140
|
+
experimentalInlineMatchResource: true,
|
|
141
|
+
...userLoaderOptions,
|
|
142
|
+
compilerOptions
|
|
143
|
+
};
|
|
144
|
+
const rule = chain.module.rule(CHAIN_ID.RULE.VUE);
|
|
145
|
+
rule.test(VUE_REGEXP).use(CHAIN_ID.USE.VUE).loader(__require.resolve("vue-loader")).options(vueLoaderOptions);
|
|
146
|
+
if (chain.module.rules.has(CHAIN_ID.RULE.JS)) {
|
|
147
|
+
applyResolveConfig(rule, chain.module.rule(CHAIN_ID.RULE.JS));
|
|
148
|
+
}
|
|
149
|
+
chain.module.rule(CHAIN_ID.RULE.CSS).test(/\.(?:css|postcss|pcss)$/);
|
|
150
|
+
chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_PLUGIN).use(VueLoaderPlugin);
|
|
151
|
+
chain.plugin("vue-loader-15-pitch-fix").use(VueLoader15PitchFixPlugin);
|
|
56
152
|
});
|
|
153
|
+
applySplitChunksRule(api, options.splitChunks);
|
|
57
154
|
}
|
|
58
155
|
};
|
|
59
156
|
}
|
|
60
|
-
|
|
61
|
-
|
|
157
|
+
function applyResolveConfig(vueRule, jsRule) {
|
|
158
|
+
const fullySpecified = jsRule.resolve.get("fullySpecified");
|
|
159
|
+
const aliases = jsRule.resolve.alias.entries();
|
|
160
|
+
if (aliases) {
|
|
161
|
+
vueRule.resolve.alias.merge(aliases);
|
|
162
|
+
}
|
|
163
|
+
if (fullySpecified !== void 0) {
|
|
164
|
+
vueRule.resolve.fullySpecified(fullySpecified);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
export {
|
|
168
|
+
PLUGIN_VUE2_NAME,
|
|
62
169
|
pluginVue2
|
|
63
|
-
}
|
|
170
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-vue2",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1-beta.1",
|
|
4
4
|
"description": "Vue 2 plugin of Rsbuild",
|
|
5
5
|
"homepage": "https://rsbuild.dev",
|
|
6
6
|
"repository": {
|
|
@@ -9,31 +9,31 @@
|
|
|
9
9
|
"directory": "packages/plugin-vue2"
|
|
10
10
|
},
|
|
11
11
|
"license": "MIT",
|
|
12
|
+
"type": "module",
|
|
12
13
|
"exports": {
|
|
13
14
|
".": {
|
|
14
15
|
"types": "./dist/index.d.ts",
|
|
15
|
-
"import": "./dist/index.
|
|
16
|
-
"
|
|
16
|
+
"import": "./dist/index.js",
|
|
17
|
+
"require": "./dist/index.cjs"
|
|
17
18
|
}
|
|
18
19
|
},
|
|
19
|
-
"main": "./dist/index.
|
|
20
|
+
"main": "./dist/index.cjs",
|
|
20
21
|
"types": "./dist/index.d.ts",
|
|
21
22
|
"files": [
|
|
22
23
|
"dist"
|
|
23
24
|
],
|
|
24
25
|
"dependencies": {
|
|
25
26
|
"vue-loader": "^15.11.1",
|
|
26
|
-
"webpack": "^5.
|
|
27
|
-
"@rsbuild/shared": "1.0.0"
|
|
27
|
+
"webpack": "^5.93.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"typescript": "^5.
|
|
31
|
-
"webpack": "^5.
|
|
32
|
-
"@rsbuild/core": "1.0.
|
|
33
|
-
"@
|
|
30
|
+
"typescript": "^5.5.2",
|
|
31
|
+
"webpack": "^5.93.0",
|
|
32
|
+
"@rsbuild/core": "1.0.1-beta.1",
|
|
33
|
+
"@scripts/test-helper": "1.0.1-beta.1"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@rsbuild/core": "^1.0.0"
|
|
36
|
+
"@rsbuild/core": "^1.0.1-beta.0"
|
|
37
37
|
},
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"access": "public",
|
package/dist/index.mjs
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
-
}) : x)(function(x) {
|
|
4
|
-
if (typeof require !== "undefined")
|
|
5
|
-
return require.apply(this, arguments);
|
|
6
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
// ../../node_modules/.pnpm/@modern-js+module-tools@2.40.0_typescript@5.3.2/node_modules/@modern-js/module-tools/shims/esm.js
|
|
10
|
-
import { fileURLToPath } from "url";
|
|
11
|
-
import path from "path";
|
|
12
|
-
|
|
13
|
-
// ../../scripts/require_shims.js
|
|
14
|
-
import { createRequire } from "module";
|
|
15
|
-
global.require = createRequire(import.meta.url);
|
|
16
|
-
|
|
17
|
-
// src/index.ts
|
|
18
|
-
import { deepmerge } from "@rsbuild/shared";
|
|
19
|
-
import { VueLoaderPlugin } from "vue-loader";
|
|
20
|
-
function pluginVue2(options = {}) {
|
|
21
|
-
return {
|
|
22
|
-
name: "rsbuild:vue2",
|
|
23
|
-
setup(api) {
|
|
24
|
-
api.modifyBundlerChain((chain, { CHAIN_ID }) => {
|
|
25
|
-
chain.resolve.extensions.add(".vue");
|
|
26
|
-
const vueLoaderOptions = deepmerge(
|
|
27
|
-
{
|
|
28
|
-
compilerOptions: {
|
|
29
|
-
preserveWhitespace: false
|
|
30
|
-
},
|
|
31
|
-
experimentalInlineMatchResource: true
|
|
32
|
-
},
|
|
33
|
-
options.vueLoaderOptions ?? {}
|
|
34
|
-
);
|
|
35
|
-
chain.module.rule(CHAIN_ID.RULE.VUE).test(/\.vue$/).use(CHAIN_ID.USE.VUE).loader(__require.resolve("vue-loader")).options(vueLoaderOptions);
|
|
36
|
-
chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_PLUGIN).use(VueLoaderPlugin);
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
export {
|
|
42
|
-
pluginVue2
|
|
43
|
-
};
|