@rsbuild/plugin-vue 0.6.14 → 0.7.0-beta.0

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 ADDED
@@ -0,0 +1,117 @@
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 __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ pluginVue: () => pluginVue
34
+ });
35
+ module.exports = __toCommonJS(src_exports);
36
+ var import_shared2 = require("@rsbuild/shared");
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 = [
57
+ "vue",
58
+ "vue-loader",
59
+ /@vue[\\/](shared|reactivity|runtime-dom|runtime-core)/
60
+ ];
61
+ }
62
+ if (options.router) {
63
+ extraGroups.router = ["vue-router"];
64
+ }
65
+ if (!Object.keys(extraGroups).length) {
66
+ return;
67
+ }
68
+ chain.optimization.splitChunks({
69
+ ...currentConfig,
70
+ // @ts-expect-error Rspack and Webpack uses different cacheGroups type
71
+ cacheGroups: {
72
+ ...currentConfig.cacheGroups,
73
+ ...(0, import_shared.createCacheGroups)(extraGroups)
74
+ }
75
+ });
76
+ });
77
+ };
78
+
79
+ // src/index.ts
80
+ function pluginVue(options = {}) {
81
+ return {
82
+ name: "rsbuild:vue",
83
+ setup(api) {
84
+ api.modifyRsbuildConfig((config, { mergeRsbuildConfig }) => {
85
+ return mergeRsbuildConfig(config, {
86
+ source: {
87
+ define: {
88
+ // https://link.vuejs.org/feature-flags
89
+ __VUE_OPTIONS_API__: true,
90
+ __VUE_PROD_DEVTOOLS__: false,
91
+ __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false
92
+ }
93
+ }
94
+ });
95
+ });
96
+ api.modifyBundlerChain(async (chain, { CHAIN_ID }) => {
97
+ chain.resolve.extensions.add(".vue");
98
+ const vueLoaderOptions = (0, import_shared2.deepmerge)(
99
+ {
100
+ compilerOptions: {
101
+ preserveWhitespace: false
102
+ },
103
+ experimentalInlineMatchResource: true
104
+ },
105
+ options.vueLoaderOptions ?? {}
106
+ );
107
+ chain.module.rule(CHAIN_ID.RULE.VUE).test(/\.vue$/).use(CHAIN_ID.USE.VUE).loader(require.resolve("vue-loader")).options(vueLoaderOptions);
108
+ chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_PLUGIN).use(import_vue_loader.VueLoaderPlugin);
109
+ });
110
+ applySplitChunksRule(api, options.splitChunks);
111
+ }
112
+ };
113
+ }
114
+ // Annotate the CommonJS export names for ESM import in node:
115
+ 0 && (module.exports = {
116
+ pluginVue
117
+ });
package/dist/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
- import { RsbuildPlugin } from '@rsbuild/core';
2
- import { VueLoaderOptions } from 'vue-loader';
3
-
4
- type SplitVueChunkOptions = {
1
+ import type { RsbuildPlugin } from '@rsbuild/core';
2
+ import type { VueLoaderOptions } from 'vue-loader';
3
+ export type SplitVueChunkOptions = {
5
4
  /**
6
5
  * Whether to enable split chunking for Vue-related dependencies (e.g., vue, vue-loader).
7
6
  * @default true
@@ -13,7 +12,7 @@ type SplitVueChunkOptions = {
13
12
  */
14
13
  router?: boolean;
15
14
  };
16
- type PluginVueOptions = {
15
+ export type PluginVueOptions = {
17
16
  /**
18
17
  * Options passed to `vue-loader`.
19
18
  * @see https://vue-loader.vuejs.org/
@@ -24,6 +23,4 @@ type PluginVueOptions = {
24
23
  */
25
24
  splitChunks?: SplitVueChunkOptions;
26
25
  };
27
- declare function pluginVue(options?: PluginVueOptions): RsbuildPlugin;
28
-
29
- export { type PluginVueOptions, type SplitVueChunkOptions, pluginVue };
26
+ export declare function pluginVue(options?: PluginVueOptions): RsbuildPlugin;
package/dist/index.js CHANGED
@@ -1,43 +1,27 @@
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 __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ import { createRequire } from 'module';
2
+ var require = createRequire(import.meta['url']);
29
3
 
30
- // src/index.ts
31
- var src_exports = {};
32
- __export(src_exports, {
33
- pluginVue: () => pluginVue
4
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
5
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
6
+ }) : x)(function(x) {
7
+ if (typeof require !== "undefined")
8
+ return require.apply(this, arguments);
9
+ throw Error('Dynamic require of "' + x + '" is not supported');
34
10
  });
35
- module.exports = __toCommonJS(src_exports);
36
- var import_shared2 = require("@rsbuild/shared");
37
- var import_vue_loader = require("vue-loader");
11
+
12
+ // ../../node_modules/.pnpm/@modern-js+module-tools@2.49.3_eslint@8.57.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js
13
+ import { fileURLToPath } from "url";
14
+ import path from "path";
15
+
16
+ // src/index.ts
17
+ import { deepmerge } from "@rsbuild/shared";
18
+ import { VueLoaderPlugin } from "vue-loader";
38
19
 
39
20
  // src/splitChunks.ts
40
- var import_shared = require("@rsbuild/shared");
21
+ import {
22
+ createCacheGroups,
23
+ isPlainObject
24
+ } from "@rsbuild/shared";
41
25
  var applySplitChunksRule = (api, options = {
42
26
  vue: true,
43
27
  router: true
@@ -48,7 +32,7 @@ var applySplitChunksRule = (api, options = {
48
32
  return;
49
33
  }
50
34
  const currentConfig = chain.optimization.splitChunks.values();
51
- if (!(0, import_shared.isPlainObject)(currentConfig)) {
35
+ if (!isPlainObject(currentConfig)) {
52
36
  return;
53
37
  }
54
38
  const extraGroups = {};
@@ -70,7 +54,7 @@ var applySplitChunksRule = (api, options = {
70
54
  // @ts-expect-error Rspack and Webpack uses different cacheGroups type
71
55
  cacheGroups: {
72
56
  ...currentConfig.cacheGroups,
73
- ...(0, import_shared.createCacheGroups)(extraGroups)
57
+ ...createCacheGroups(extraGroups)
74
58
  }
75
59
  });
76
60
  });
@@ -95,7 +79,7 @@ function pluginVue(options = {}) {
95
79
  });
96
80
  api.modifyBundlerChain(async (chain, { CHAIN_ID }) => {
97
81
  chain.resolve.extensions.add(".vue");
98
- const vueLoaderOptions = (0, import_shared2.deepmerge)(
82
+ const vueLoaderOptions = deepmerge(
99
83
  {
100
84
  compilerOptions: {
101
85
  preserveWhitespace: false
@@ -104,14 +88,13 @@ function pluginVue(options = {}) {
104
88
  },
105
89
  options.vueLoaderOptions ?? {}
106
90
  );
107
- chain.module.rule(CHAIN_ID.RULE.VUE).test(/\.vue$/).use(CHAIN_ID.USE.VUE).loader(require.resolve("vue-loader")).options(vueLoaderOptions);
108
- chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_PLUGIN).use(import_vue_loader.VueLoaderPlugin);
91
+ chain.module.rule(CHAIN_ID.RULE.VUE).test(/\.vue$/).use(CHAIN_ID.USE.VUE).loader(__require.resolve("vue-loader")).options(vueLoaderOptions);
92
+ chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_PLUGIN).use(VueLoaderPlugin);
109
93
  });
110
94
  applySplitChunksRule(api, options.splitChunks);
111
95
  }
112
96
  };
113
97
  }
114
- // Annotate the CommonJS export names for ESM import in node:
115
- 0 && (module.exports = {
98
+ export {
116
99
  pluginVue
117
- });
100
+ };
@@ -0,0 +1,3 @@
1
+ import type { RsbuildPluginAPI } from '@rsbuild/core';
2
+ import type { SplitVueChunkOptions } from '.';
3
+ export declare const applySplitChunksRule: (api: RsbuildPluginAPI, options?: SplitVueChunkOptions) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-vue",
3
- "version": "0.6.14",
3
+ "version": "0.7.0-beta.0",
4
4
  "description": "Vue 3 plugin of Rsbuild",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "repository": {
@@ -9,15 +9,15 @@
9
9
  "directory": "packages/plugin-vue"
10
10
  },
11
11
  "license": "MIT",
12
- "type": "commonjs",
12
+ "type": "module",
13
13
  "exports": {
14
14
  ".": {
15
15
  "types": "./dist/index.d.ts",
16
- "import": "./dist/index.mjs",
17
- "default": "./dist/index.js"
16
+ "import": "./dist/index.js",
17
+ "require": "./dist/index.cjs"
18
18
  }
19
19
  },
20
- "main": "./dist/index.js",
20
+ "main": "./dist/index.cjs",
21
21
  "types": "./dist/index.d.ts",
22
22
  "files": [
23
23
  "dist"
@@ -25,17 +25,17 @@
25
25
  "dependencies": {
26
26
  "vue-loader": "^17.4.0",
27
27
  "webpack": "^5.91.0",
28
- "@rsbuild/shared": "0.6.14"
28
+ "@rsbuild/shared": "0.7.0-beta.0"
29
29
  },
30
30
  "devDependencies": {
31
31
  "typescript": "^5.4.2",
32
32
  "vue": "^3.4.19",
33
33
  "webpack": "^5.91.0",
34
- "@rsbuild/core": "0.6.14",
35
- "@scripts/test-helper": "0.6.14"
34
+ "@rsbuild/core": "0.7.0-beta.0",
35
+ "@scripts/test-helper": "0.7.0-beta.0"
36
36
  },
37
37
  "peerDependencies": {
38
- "@rsbuild/core": "^0.6.14"
38
+ "@rsbuild/core": "^0.7.0-beta.0"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public",
package/dist/index.mjs DELETED
@@ -1,100 +0,0 @@
1
- import { createRequire } from 'module';
2
- var require = createRequire(import.meta['url']);
3
-
4
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
5
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
6
- }) : x)(function(x) {
7
- if (typeof require !== "undefined")
8
- return require.apply(this, arguments);
9
- throw Error('Dynamic require of "' + x + '" is not supported');
10
- });
11
-
12
- // ../../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
13
- import { fileURLToPath } from "url";
14
- import path from "path";
15
-
16
- // src/index.ts
17
- import { deepmerge } from "@rsbuild/shared";
18
- import { VueLoaderPlugin } from "vue-loader";
19
-
20
- // src/splitChunks.ts
21
- import {
22
- createCacheGroups,
23
- isPlainObject
24
- } from "@rsbuild/shared";
25
- var applySplitChunksRule = (api, options = {
26
- vue: true,
27
- router: true
28
- }) => {
29
- api.modifyBundlerChain((chain) => {
30
- const config = api.getNormalizedConfig();
31
- if (config.performance.chunkSplit.strategy !== "split-by-experience") {
32
- return;
33
- }
34
- const currentConfig = chain.optimization.splitChunks.values();
35
- if (!isPlainObject(currentConfig)) {
36
- return;
37
- }
38
- const extraGroups = {};
39
- if (options.vue) {
40
- extraGroups.vue = [
41
- "vue",
42
- "vue-loader",
43
- /@vue[\\/](shared|reactivity|runtime-dom|runtime-core)/
44
- ];
45
- }
46
- if (options.router) {
47
- extraGroups.router = ["vue-router"];
48
- }
49
- if (!Object.keys(extraGroups).length) {
50
- return;
51
- }
52
- chain.optimization.splitChunks({
53
- ...currentConfig,
54
- // @ts-expect-error Rspack and Webpack uses different cacheGroups type
55
- cacheGroups: {
56
- ...currentConfig.cacheGroups,
57
- ...createCacheGroups(extraGroups)
58
- }
59
- });
60
- });
61
- };
62
-
63
- // src/index.ts
64
- function pluginVue(options = {}) {
65
- return {
66
- name: "rsbuild:vue",
67
- setup(api) {
68
- api.modifyRsbuildConfig((config, { mergeRsbuildConfig }) => {
69
- return mergeRsbuildConfig(config, {
70
- source: {
71
- define: {
72
- // https://link.vuejs.org/feature-flags
73
- __VUE_OPTIONS_API__: true,
74
- __VUE_PROD_DEVTOOLS__: false,
75
- __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false
76
- }
77
- }
78
- });
79
- });
80
- api.modifyBundlerChain(async (chain, { CHAIN_ID }) => {
81
- chain.resolve.extensions.add(".vue");
82
- const vueLoaderOptions = deepmerge(
83
- {
84
- compilerOptions: {
85
- preserveWhitespace: false
86
- },
87
- experimentalInlineMatchResource: true
88
- },
89
- options.vueLoaderOptions ?? {}
90
- );
91
- chain.module.rule(CHAIN_ID.RULE.VUE).test(/\.vue$/).use(CHAIN_ID.USE.VUE).loader(__require.resolve("vue-loader")).options(vueLoaderOptions);
92
- chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_PLUGIN).use(VueLoaderPlugin);
93
- });
94
- applySplitChunksRule(api, options.splitChunks);
95
- }
96
- };
97
- }
98
- export {
99
- pluginVue
100
- };