@rsbuild/plugin-vue2 0.0.0-next-20231108034054 → 0.0.0-next-20231207110454

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 CHANGED
@@ -1,6 +1,14 @@
1
- import type { RsbuildPlugin, RsbuildPluginAPI } from '@rsbuild/core';
2
- import type { VueLoaderOptions } from 'vue-loader';
3
- export type PluginVueOptions = {
4
- vueLoaderOptions?: VueLoaderOptions;
1
+ import { RsbuildPlugin } from '@rsbuild/core';
2
+ import { VueLoaderOptions } from 'vue-loader';
3
+
4
+ type SplitVueChunkOptions = {
5
+ vue?: boolean;
6
+ router?: boolean;
5
7
  };
6
- export declare function pluginVue2(options?: PluginVueOptions): RsbuildPlugin<RsbuildPluginAPI>;
8
+ type PluginVueOptions = {
9
+ vueLoaderOptions?: VueLoaderOptions;
10
+ splitChunks?: SplitVueChunkOptions;
11
+ };
12
+ declare function pluginVue2(options?: PluginVueOptions): RsbuildPlugin;
13
+
14
+ export { PluginVueOptions, SplitVueChunkOptions, pluginVue2 };
package/dist/index.js CHANGED
@@ -26,32 +26,71 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
29
31
  var src_exports = {};
30
32
  __export(src_exports, {
31
33
  pluginVue2: () => pluginVue2
32
34
  });
33
35
  module.exports = __toCommonJS(src_exports);
34
- var import_deepmerge = require("@rsbuild/shared/deepmerge");
36
+ var import_shared2 = require("@rsbuild/shared");
35
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
36
75
  function pluginVue2(options = {}) {
37
76
  return {
38
- name: "plugin-vue2",
77
+ name: "rsbuild:vue2",
39
78
  setup(api) {
40
79
  api.modifyBundlerChain((chain, { CHAIN_ID }) => {
41
- var _a;
42
80
  chain.resolve.extensions.add(".vue");
43
- const vueLoaderOptions = (0, import_deepmerge.deepmerge)(
81
+ const vueLoaderOptions = (0, import_shared2.deepmerge)(
44
82
  {
45
83
  compilerOptions: {
46
84
  preserveWhitespace: false
47
85
  },
48
86
  experimentalInlineMatchResource: true
49
87
  },
50
- (_a = options.vueLoaderOptions) != null ? _a : {}
88
+ options.vueLoaderOptions ?? {}
51
89
  );
52
90
  chain.module.rule(CHAIN_ID.RULE.VUE).test(/\.vue$/).use(CHAIN_ID.USE.VUE).loader(require.resolve("vue-loader")).options(vueLoaderOptions);
53
91
  chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_PLUGIN).use(import_vue_loader.VueLoaderPlugin);
54
92
  });
93
+ applySplitChunksRule(api, options.splitChunks);
55
94
  }
56
95
  };
57
96
  }
package/dist/index.mjs ADDED
@@ -0,0 +1,84 @@
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.41.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/requireShims.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
+
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
60
+ function pluginVue2(options = {}) {
61
+ return {
62
+ name: "rsbuild:vue2",
63
+ setup(api) {
64
+ api.modifyBundlerChain((chain, { CHAIN_ID }) => {
65
+ chain.resolve.extensions.add(".vue");
66
+ const vueLoaderOptions = deepmerge(
67
+ {
68
+ compilerOptions: {
69
+ preserveWhitespace: false
70
+ },
71
+ experimentalInlineMatchResource: true
72
+ },
73
+ options.vueLoaderOptions ?? {}
74
+ );
75
+ chain.module.rule(CHAIN_ID.RULE.VUE).test(/\.vue$/).use(CHAIN_ID.USE.VUE).loader(__require.resolve("vue-loader")).options(vueLoaderOptions);
76
+ chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_PLUGIN).use(VueLoaderPlugin);
77
+ });
78
+ applySplitChunksRule(api, options.splitChunks);
79
+ }
80
+ };
81
+ }
82
+ export {
83
+ pluginVue2
84
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-vue2",
3
- "version": "0.0.0-next-20231108034054",
3
+ "version": "0.0.0-next-20231207110454",
4
4
  "description": "Vue 2 plugin of Rsbuild",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "repository": {
@@ -9,9 +9,11 @@
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",
16
+ "import": "./dist/index.mjs",
15
17
  "default": "./dist/index.js"
16
18
  }
17
19
  },
@@ -23,16 +25,16 @@
23
25
  "dependencies": {
24
26
  "vue-loader": "^15.11.1",
25
27
  "webpack": "^5.89.0",
26
- "@rsbuild/shared": "0.0.0-next-20231108034054"
28
+ "@rsbuild/shared": "0.0.0-next-20231207110454"
27
29
  },
28
30
  "devDependencies": {
29
- "typescript": "^5.2.2",
31
+ "typescript": "^5.3.0",
30
32
  "webpack": "^5.89.0",
31
- "@rsbuild/core": "0.0.0-next-20231108034054",
32
- "@rsbuild/test-helper": "0.0.0-next-20231108034054"
33
+ "@rsbuild/test-helper": "0.0.0-next-20231207110454",
34
+ "@rsbuild/core": "0.0.0-next-20231207110454"
33
35
  },
34
36
  "peerDependencies": {
35
- "@rsbuild/core": "0.0.0-next-20231108034054"
37
+ "@rsbuild/core": "0.0.0-next-20231207110454"
36
38
  },
37
39
  "publishConfig": {
38
40
  "access": "public",