@rsbuild/plugin-vue2 0.0.0-next-20231115072032 → 0.0.0-next-20231220091832
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 +6 -1
- package/dist/index.js +42 -5
- package/dist/index.mjs +44 -3
- package/package.json +7 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { RsbuildPlugin } from '@rsbuild/core';
|
|
2
2
|
import { VueLoaderOptions } from 'vue-loader';
|
|
3
3
|
|
|
4
|
+
type SplitVueChunkOptions = {
|
|
5
|
+
vue?: boolean;
|
|
6
|
+
router?: boolean;
|
|
7
|
+
};
|
|
4
8
|
type PluginVueOptions = {
|
|
5
9
|
vueLoaderOptions?: VueLoaderOptions;
|
|
10
|
+
splitChunks?: SplitVueChunkOptions;
|
|
6
11
|
};
|
|
7
12
|
declare function pluginVue2(options?: PluginVueOptions): RsbuildPlugin;
|
|
8
13
|
|
|
9
|
-
export { PluginVueOptions, pluginVue2 };
|
|
14
|
+
export { PluginVueOptions, SplitVueChunkOptions, pluginVue2 };
|
package/dist/index.js
CHANGED
|
@@ -33,27 +33,64 @@ __export(src_exports, {
|
|
|
33
33
|
pluginVue2: () => pluginVue2
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(src_exports);
|
|
36
|
-
var
|
|
36
|
+
var import_shared2 = require("@rsbuild/shared");
|
|
37
37
|
var import_vue_loader = require("vue-loader");
|
|
38
|
+
|
|
39
|
+
// src/splitChunks.ts
|
|
40
|
+
var import_shared = require("@rsbuild/shared");
|
|
41
|
+
var applySplitChunksRule = (api, options = {
|
|
42
|
+
vue: true,
|
|
43
|
+
router: true
|
|
44
|
+
}) => {
|
|
45
|
+
api.modifyBundlerChain((chain) => {
|
|
46
|
+
const config = api.getNormalizedConfig();
|
|
47
|
+
if (config.performance.chunkSplit.strategy !== "split-by-experience") {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const currentConfig = chain.optimization.splitChunks.values();
|
|
51
|
+
if (!(0, import_shared.isPlainObject)(currentConfig)) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const extraGroups = {};
|
|
55
|
+
if (options.vue) {
|
|
56
|
+
extraGroups.vue = ["vue", "vue-loader"];
|
|
57
|
+
}
|
|
58
|
+
if (options.router) {
|
|
59
|
+
extraGroups.router = ["vue-router"];
|
|
60
|
+
}
|
|
61
|
+
if (!Object.keys(extraGroups).length) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
chain.optimization.splitChunks({
|
|
65
|
+
...currentConfig,
|
|
66
|
+
cacheGroups: {
|
|
67
|
+
...currentConfig.cacheGroups,
|
|
68
|
+
...(0, import_shared.createCacheGroups)(extraGroups)
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// src/index.ts
|
|
38
75
|
function pluginVue2(options = {}) {
|
|
39
76
|
return {
|
|
40
|
-
name: "
|
|
77
|
+
name: "rsbuild:vue2",
|
|
41
78
|
setup(api) {
|
|
42
79
|
api.modifyBundlerChain((chain, { CHAIN_ID }) => {
|
|
43
|
-
var _a;
|
|
44
80
|
chain.resolve.extensions.add(".vue");
|
|
45
|
-
const vueLoaderOptions = (0,
|
|
81
|
+
const vueLoaderOptions = (0, import_shared2.deepmerge)(
|
|
46
82
|
{
|
|
47
83
|
compilerOptions: {
|
|
48
84
|
preserveWhitespace: false
|
|
49
85
|
},
|
|
50
86
|
experimentalInlineMatchResource: true
|
|
51
87
|
},
|
|
52
|
-
|
|
88
|
+
options.vueLoaderOptions ?? {}
|
|
53
89
|
);
|
|
54
90
|
chain.module.rule(CHAIN_ID.RULE.VUE).test(/\.vue$/).use(CHAIN_ID.USE.VUE).loader(require.resolve("vue-loader")).options(vueLoaderOptions);
|
|
55
91
|
chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_PLUGIN).use(import_vue_loader.VueLoaderPlugin);
|
|
56
92
|
});
|
|
93
|
+
applySplitChunksRule(api, options.splitChunks);
|
|
57
94
|
}
|
|
58
95
|
};
|
|
59
96
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -6,20 +6,60 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
6
6
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
7
|
});
|
|
8
8
|
|
|
9
|
-
// ../../node_modules/.pnpm/@modern-js+module-tools@2.
|
|
9
|
+
// ../../node_modules/.pnpm/@modern-js+module-tools@2.41.0_typescript@5.3.2/node_modules/@modern-js/module-tools/shims/esm.js
|
|
10
10
|
import { fileURLToPath } from "url";
|
|
11
11
|
import path from "path";
|
|
12
12
|
|
|
13
|
-
// ../../scripts/
|
|
13
|
+
// ../../scripts/requireShims.js
|
|
14
14
|
import { createRequire } from "module";
|
|
15
15
|
global.require = createRequire(import.meta.url);
|
|
16
16
|
|
|
17
17
|
// src/index.ts
|
|
18
18
|
import { deepmerge } from "@rsbuild/shared";
|
|
19
19
|
import { VueLoaderPlugin } from "vue-loader";
|
|
20
|
+
|
|
21
|
+
// src/splitChunks.ts
|
|
22
|
+
import {
|
|
23
|
+
isPlainObject,
|
|
24
|
+
createCacheGroups
|
|
25
|
+
} from "@rsbuild/shared";
|
|
26
|
+
var applySplitChunksRule = (api, options = {
|
|
27
|
+
vue: true,
|
|
28
|
+
router: true
|
|
29
|
+
}) => {
|
|
30
|
+
api.modifyBundlerChain((chain) => {
|
|
31
|
+
const config = api.getNormalizedConfig();
|
|
32
|
+
if (config.performance.chunkSplit.strategy !== "split-by-experience") {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const currentConfig = chain.optimization.splitChunks.values();
|
|
36
|
+
if (!isPlainObject(currentConfig)) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const extraGroups = {};
|
|
40
|
+
if (options.vue) {
|
|
41
|
+
extraGroups.vue = ["vue", "vue-loader"];
|
|
42
|
+
}
|
|
43
|
+
if (options.router) {
|
|
44
|
+
extraGroups.router = ["vue-router"];
|
|
45
|
+
}
|
|
46
|
+
if (!Object.keys(extraGroups).length) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
chain.optimization.splitChunks({
|
|
50
|
+
...currentConfig,
|
|
51
|
+
cacheGroups: {
|
|
52
|
+
...currentConfig.cacheGroups,
|
|
53
|
+
...createCacheGroups(extraGroups)
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// src/index.ts
|
|
20
60
|
function pluginVue2(options = {}) {
|
|
21
61
|
return {
|
|
22
|
-
name: "
|
|
62
|
+
name: "rsbuild:vue2",
|
|
23
63
|
setup(api) {
|
|
24
64
|
api.modifyBundlerChain((chain, { CHAIN_ID }) => {
|
|
25
65
|
chain.resolve.extensions.add(".vue");
|
|
@@ -35,6 +75,7 @@ function pluginVue2(options = {}) {
|
|
|
35
75
|
chain.module.rule(CHAIN_ID.RULE.VUE).test(/\.vue$/).use(CHAIN_ID.USE.VUE).loader(__require.resolve("vue-loader")).options(vueLoaderOptions);
|
|
36
76
|
chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_PLUGIN).use(VueLoaderPlugin);
|
|
37
77
|
});
|
|
78
|
+
applySplitChunksRule(api, options.splitChunks);
|
|
38
79
|
}
|
|
39
80
|
};
|
|
40
81
|
}
|
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-20231220091832",
|
|
4
4
|
"description": "Vue 2 plugin of Rsbuild",
|
|
5
5
|
"homepage": "https://rsbuild.dev",
|
|
6
6
|
"repository": {
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"directory": "packages/plugin-vue2"
|
|
10
10
|
},
|
|
11
11
|
"license": "MIT",
|
|
12
|
+
"type": "commonjs",
|
|
12
13
|
"exports": {
|
|
13
14
|
".": {
|
|
14
15
|
"types": "./dist/index.d.ts",
|
|
@@ -24,16 +25,16 @@
|
|
|
24
25
|
"dependencies": {
|
|
25
26
|
"vue-loader": "^15.11.1",
|
|
26
27
|
"webpack": "^5.89.0",
|
|
27
|
-
"@rsbuild/shared": "0.0.0-next-
|
|
28
|
+
"@rsbuild/shared": "0.0.0-next-20231220091832"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
|
-
"typescript": "^5.
|
|
31
|
+
"typescript": "^5.3.0",
|
|
31
32
|
"webpack": "^5.89.0",
|
|
32
|
-
"@rsbuild/
|
|
33
|
-
"@rsbuild/
|
|
33
|
+
"@rsbuild/test-helper": "0.0.0-next-20231220091832",
|
|
34
|
+
"@rsbuild/core": "0.0.0-next-20231220091832"
|
|
34
35
|
},
|
|
35
36
|
"peerDependencies": {
|
|
36
|
-
"@rsbuild/core": "0.0.0-next-
|
|
37
|
+
"@rsbuild/core": "0.0.0-next-20231220091832"
|
|
37
38
|
},
|
|
38
39
|
"publishConfig": {
|
|
39
40
|
"access": "public",
|