@rsbuild/plugin-vue 1.0.1 → 1.0.2

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 CHANGED
@@ -1,136 +1,131 @@
1
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
- PLUGIN_VUE_NAME: () => PLUGIN_VUE_NAME,
34
- pluginVue: () => pluginVue
2
+ // The require scope
3
+ var __webpack_require__ = {};
4
+ /************************************************************************/ // webpack/runtime/define_property_getters
5
+ (()=>{
6
+ __webpack_require__.d = function(exports1, definition) {
7
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
8
+ enumerable: true,
9
+ get: definition[key]
10
+ });
11
+ };
12
+ })();
13
+ // webpack/runtime/has_own_property
14
+ (()=>{
15
+ __webpack_require__.o = function(obj, prop) {
16
+ return Object.prototype.hasOwnProperty.call(obj, prop);
17
+ };
18
+ })();
19
+ // webpack/runtime/make_namespace_object
20
+ (()=>{
21
+ // define __esModule on exports
22
+ __webpack_require__.r = function(exports1) {
23
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
24
+ value: 'Module'
25
+ });
26
+ Object.defineProperty(exports1, '__esModule', {
27
+ value: true
28
+ });
29
+ };
30
+ })();
31
+ /************************************************************************/ var __webpack_exports__ = {};
32
+ // ESM COMPAT FLAG
33
+ __webpack_require__.r(__webpack_exports__);
34
+ // EXPORTS
35
+ __webpack_require__.d(__webpack_exports__, {
36
+ pluginVue: ()=>/* binding */ pluginVue,
37
+ PLUGIN_VUE_NAME: ()=>/* binding */ PLUGIN_VUE_NAME
35
38
  });
36
- module.exports = __toCommonJS(src_exports);
37
- var import_vue_loader = require("vue-loader");
38
-
39
- // src/splitChunks.ts
40
- var isPlainObject = (obj) => obj !== null && typeof obj === "object" && Object.prototype.toString.call(obj) === "[object Object]";
41
- var applySplitChunksRule = (api, options = {
42
- vue: true,
43
- router: true
44
- }) => {
45
- api.modifyBundlerChain((chain, { environment }) => {
46
- const { config } = environment;
47
- if (config.performance.chunkSplit.strategy !== "split-by-experience") {
48
- return;
49
- }
50
- const currentConfig = chain.optimization.splitChunks.values();
51
- if (!isPlainObject(currentConfig)) {
52
- return;
53
- }
54
- const extraGroups = {};
55
- if (options.vue) {
56
- extraGroups.vue = {
57
- name: "lib-vue",
58
- test: /node_modules[\\/](?:vue|vue-loader|@vue[\\/]shared|@vue[\\/]reactivity|@vue[\\/]runtime-dom|@vue[\\/]runtime-core)[\\/]/,
59
- priority: 0
60
- };
61
- }
62
- if (options.router) {
63
- extraGroups.router = {
64
- name: "lib-router",
65
- test: /node_modules[\\/]vue-router[\\/]/,
66
- priority: 0
67
- };
68
- }
69
- if (!Object.keys(extraGroups).length) {
70
- return;
71
- }
72
- chain.optimization.splitChunks({
73
- ...currentConfig,
74
- cacheGroups: {
75
- ...currentConfig.cacheGroups,
76
- ...extraGroups
77
- }
78
- });
79
- });
80
- };
81
-
82
- // src/index.ts
83
- var PLUGIN_VUE_NAME = "rsbuild:vue";
84
- function pluginVue(options = {}) {
85
- return {
86
- name: PLUGIN_VUE_NAME,
87
- setup(api) {
88
- const VUE_REGEXP = /\.vue$/;
89
- const CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
90
- api.modifyEnvironmentConfig((config, { mergeEnvironmentConfig }) => {
91
- const extraConfig = {
92
- source: {
93
- define: {
94
- // https://link.vuejs.org/feature-flags
95
- __VUE_OPTIONS_API__: true,
96
- __VUE_PROD_DEVTOOLS__: false,
97
- __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false
98
- }
99
- }
39
+ const external_node_module_namespaceObject = require("node:module");
40
+ const external_vue_loader_namespaceObject = require("vue-loader");
41
+ const isPlainObject = (obj)=>null !== obj && 'object' == typeof obj && '[object Object]' === Object.prototype.toString.call(obj);
42
+ const applySplitChunksRule = function(api) {
43
+ let options = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {
44
+ vue: true,
45
+ router: true
46
+ };
47
+ api.modifyBundlerChain((chain, param)=>{
48
+ let { environment } = param;
49
+ const { config } = environment;
50
+ if ('split-by-experience' !== config.performance.chunkSplit.strategy) return;
51
+ const currentConfig = chain.optimization.splitChunks.values();
52
+ if (!isPlainObject(currentConfig)) return;
53
+ const extraGroups = {};
54
+ if (options.vue) extraGroups.vue = {
55
+ name: 'lib-vue',
56
+ test: /node_modules[\\/](?:vue|vue-loader|@vue[\\/]shared|@vue[\\/]reactivity|@vue[\\/]runtime-dom|@vue[\\/]runtime-core)[\\/]/,
57
+ priority: 0
100
58
  };
101
- const merged = mergeEnvironmentConfig(extraConfig, config);
102
- if (merged.output.cssModules.auto === true) {
103
- merged.output.cssModules.auto = (path, query) => {
104
- if (VUE_REGEXP.test(path)) {
105
- return query.includes("type=style") && query.includes("module=true");
59
+ if (options.router) extraGroups.router = {
60
+ name: 'lib-router',
61
+ test: /node_modules[\\/]vue-router[\\/]/,
62
+ priority: 0
63
+ };
64
+ if (!Object.keys(extraGroups).length) return;
65
+ chain.optimization.splitChunks({
66
+ ...currentConfig,
67
+ cacheGroups: {
68
+ ...currentConfig.cacheGroups,
69
+ ...extraGroups
106
70
  }
107
- return CSS_MODULES_REGEX.test(path);
108
- };
71
+ });
72
+ });
73
+ };
74
+ const src_require = (0, external_node_module_namespaceObject.createRequire)(/*#__PURE__*/ function() {
75
+ return 'undefined' == typeof document ? new (module.require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
76
+ }());
77
+ const PLUGIN_VUE_NAME = 'rsbuild:vue';
78
+ function pluginVue() {
79
+ let options = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
80
+ return {
81
+ name: PLUGIN_VUE_NAME,
82
+ setup (api) {
83
+ const VUE_REGEXP = /\.vue$/;
84
+ const CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
85
+ api.modifyEnvironmentConfig((config, param)=>{
86
+ let { mergeEnvironmentConfig } = param;
87
+ const extraConfig = {
88
+ source: {
89
+ define: {
90
+ // https://link.vuejs.org/feature-flags
91
+ __VUE_OPTIONS_API__: true,
92
+ __VUE_PROD_DEVTOOLS__: false,
93
+ __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false
94
+ }
95
+ }
96
+ };
97
+ const merged = mergeEnvironmentConfig(extraConfig, config);
98
+ // Support `<style module>` in Vue SFC
99
+ if (true === merged.output.cssModules.auto) merged.output.cssModules.auto = (path, query)=>{
100
+ if (VUE_REGEXP.test(path)) return query.includes('type=style') && query.includes('module=true');
101
+ return CSS_MODULES_REGEX.test(path);
102
+ };
103
+ return merged;
104
+ });
105
+ api.modifyBundlerChain(async (chain, param)=>{
106
+ let { CHAIN_ID } = param;
107
+ chain.resolve.extensions.add('.vue');
108
+ const userLoaderOptions = options.vueLoaderOptions ?? {};
109
+ const compilerOptions = {
110
+ preserveWhitespace: false,
111
+ ...userLoaderOptions.compilerOptions
112
+ };
113
+ const vueLoaderOptions = {
114
+ experimentalInlineMatchResource: true,
115
+ ...userLoaderOptions,
116
+ compilerOptions
117
+ };
118
+ chain.module.rule(CHAIN_ID.RULE.VUE).test(VUE_REGEXP).use(CHAIN_ID.USE.VUE).loader(src_require.resolve('vue-loader')).options(vueLoaderOptions);
119
+ // Support for lang="postcss" and lang="pcss" in SFC
120
+ chain.module.rule(CHAIN_ID.RULE.CSS).test(/\.(?:css|postcss|pcss)$/);
121
+ chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_PLUGIN).use(external_vue_loader_namespaceObject.VueLoaderPlugin);
122
+ });
123
+ applySplitChunksRule(api, options.splitChunks);
109
124
  }
110
- return merged;
111
- });
112
- api.modifyBundlerChain(async (chain, { CHAIN_ID }) => {
113
- chain.resolve.extensions.add(".vue");
114
- const userLoaderOptions = options.vueLoaderOptions ?? {};
115
- const compilerOptions = {
116
- preserveWhitespace: false,
117
- ...userLoaderOptions.compilerOptions
118
- };
119
- const vueLoaderOptions = {
120
- experimentalInlineMatchResource: true,
121
- ...userLoaderOptions,
122
- compilerOptions
123
- };
124
- chain.module.rule(CHAIN_ID.RULE.VUE).test(VUE_REGEXP).use(CHAIN_ID.USE.VUE).loader(require.resolve("vue-loader")).options(vueLoaderOptions);
125
- chain.module.rule(CHAIN_ID.RULE.CSS).test(/\.(?:css|postcss|pcss)$/);
126
- chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_PLUGIN).use(import_vue_loader.VueLoaderPlugin);
127
- });
128
- applySplitChunksRule(api, options.splitChunks);
129
- }
130
- };
125
+ };
131
126
  }
132
- // Annotate the CommonJS export names for ESM import in node:
133
- 0 && (module.exports = {
134
- PLUGIN_VUE_NAME,
135
- pluginVue
127
+ var __webpack_export_target__ = exports;
128
+ for(var i in __webpack_exports__)__webpack_export_target__[i] = __webpack_exports__[i];
129
+ if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
130
+ value: true
136
131
  });
package/dist/index.js CHANGED
@@ -1,115 +1,87 @@
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.59.0_typescript@5.5.2/node_modules/@modern-js/module-tools/shims/esm.js
13
- import path from "path";
14
- import { fileURLToPath } from "url";
15
-
16
- // src/index.ts
17
- import { VueLoaderPlugin } from "vue-loader";
18
-
19
- // src/splitChunks.ts
20
- var isPlainObject = (obj) => obj !== null && typeof obj === "object" && Object.prototype.toString.call(obj) === "[object Object]";
21
- var applySplitChunksRule = (api, options = {
22
- vue: true,
23
- router: true
24
- }) => {
25
- api.modifyBundlerChain((chain, { environment }) => {
26
- const { config } = environment;
27
- if (config.performance.chunkSplit.strategy !== "split-by-experience") {
28
- return;
29
- }
30
- const currentConfig = chain.optimization.splitChunks.values();
31
- if (!isPlainObject(currentConfig)) {
32
- return;
33
- }
34
- const extraGroups = {};
35
- if (options.vue) {
36
- extraGroups.vue = {
37
- name: "lib-vue",
38
- test: /node_modules[\\/](?:vue|vue-loader|@vue[\\/]shared|@vue[\\/]reactivity|@vue[\\/]runtime-dom|@vue[\\/]runtime-core)[\\/]/,
39
- priority: 0
40
- };
41
- }
42
- if (options.router) {
43
- extraGroups.router = {
44
- name: "lib-router",
45
- test: /node_modules[\\/]vue-router[\\/]/,
46
- priority: 0
47
- };
48
- }
49
- if (!Object.keys(extraGroups).length) {
50
- return;
51
- }
52
- chain.optimization.splitChunks({
53
- ...currentConfig,
54
- cacheGroups: {
55
- ...currentConfig.cacheGroups,
56
- ...extraGroups
57
- }
58
- });
59
- });
60
- };
61
-
62
- // src/index.ts
63
- var PLUGIN_VUE_NAME = "rsbuild:vue";
64
- function pluginVue(options = {}) {
65
- return {
66
- name: PLUGIN_VUE_NAME,
67
- setup(api) {
68
- const VUE_REGEXP = /\.vue$/;
69
- const CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
70
- api.modifyEnvironmentConfig((config, { mergeEnvironmentConfig }) => {
71
- const extraConfig = {
72
- source: {
73
- define: {
74
- // https://link.vuejs.org/feature-flags
75
- __VUE_OPTIONS_API__: true,
76
- __VUE_PROD_DEVTOOLS__: false,
77
- __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false
78
- }
79
- }
1
+ import * as __WEBPACK_EXTERNAL_MODULE_node_module__ from "node:module";
2
+ import * as __WEBPACK_EXTERNAL_MODULE_vue_loader__ from "vue-loader";
3
+ const isPlainObject = (obj)=>null !== obj && 'object' == typeof obj && '[object Object]' === Object.prototype.toString.call(obj);
4
+ const applySplitChunksRule = function(api) {
5
+ let options = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {
6
+ vue: true,
7
+ router: true
8
+ };
9
+ api.modifyBundlerChain((chain, param)=>{
10
+ let { environment } = param;
11
+ const { config } = environment;
12
+ if ('split-by-experience' !== config.performance.chunkSplit.strategy) return;
13
+ const currentConfig = chain.optimization.splitChunks.values();
14
+ if (!isPlainObject(currentConfig)) return;
15
+ const extraGroups = {};
16
+ if (options.vue) extraGroups.vue = {
17
+ name: 'lib-vue',
18
+ test: /node_modules[\\/](?:vue|vue-loader|@vue[\\/]shared|@vue[\\/]reactivity|@vue[\\/]runtime-dom|@vue[\\/]runtime-core)[\\/]/,
19
+ priority: 0
80
20
  };
81
- const merged = mergeEnvironmentConfig(extraConfig, config);
82
- if (merged.output.cssModules.auto === true) {
83
- merged.output.cssModules.auto = (path2, query) => {
84
- if (VUE_REGEXP.test(path2)) {
85
- return query.includes("type=style") && query.includes("module=true");
21
+ if (options.router) extraGroups.router = {
22
+ name: 'lib-router',
23
+ test: /node_modules[\\/]vue-router[\\/]/,
24
+ priority: 0
25
+ };
26
+ if (!Object.keys(extraGroups).length) return;
27
+ chain.optimization.splitChunks({
28
+ ...currentConfig,
29
+ cacheGroups: {
30
+ ...currentConfig.cacheGroups,
31
+ ...extraGroups
86
32
  }
87
- return CSS_MODULES_REGEX.test(path2);
88
- };
33
+ });
34
+ });
35
+ };
36
+ const src_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module__.createRequire)(import.meta.url);
37
+ const PLUGIN_VUE_NAME = 'rsbuild:vue';
38
+ function pluginVue() {
39
+ let options = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
40
+ return {
41
+ name: PLUGIN_VUE_NAME,
42
+ setup (api) {
43
+ const VUE_REGEXP = /\.vue$/;
44
+ const CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
45
+ api.modifyEnvironmentConfig((config, param)=>{
46
+ let { mergeEnvironmentConfig } = param;
47
+ const extraConfig = {
48
+ source: {
49
+ define: {
50
+ // https://link.vuejs.org/feature-flags
51
+ __VUE_OPTIONS_API__: true,
52
+ __VUE_PROD_DEVTOOLS__: false,
53
+ __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false
54
+ }
55
+ }
56
+ };
57
+ const merged = mergeEnvironmentConfig(extraConfig, config);
58
+ // Support `<style module>` in Vue SFC
59
+ if (true === merged.output.cssModules.auto) merged.output.cssModules.auto = (path, query)=>{
60
+ if (VUE_REGEXP.test(path)) return query.includes('type=style') && query.includes('module=true');
61
+ return CSS_MODULES_REGEX.test(path);
62
+ };
63
+ return merged;
64
+ });
65
+ api.modifyBundlerChain(async (chain, param)=>{
66
+ let { CHAIN_ID } = param;
67
+ chain.resolve.extensions.add('.vue');
68
+ const userLoaderOptions = options.vueLoaderOptions ?? {};
69
+ const compilerOptions = {
70
+ preserveWhitespace: false,
71
+ ...userLoaderOptions.compilerOptions
72
+ };
73
+ const vueLoaderOptions = {
74
+ experimentalInlineMatchResource: true,
75
+ ...userLoaderOptions,
76
+ compilerOptions
77
+ };
78
+ chain.module.rule(CHAIN_ID.RULE.VUE).test(VUE_REGEXP).use(CHAIN_ID.USE.VUE).loader(src_require.resolve('vue-loader')).options(vueLoaderOptions);
79
+ // Support for lang="postcss" and lang="pcss" in SFC
80
+ chain.module.rule(CHAIN_ID.RULE.CSS).test(/\.(?:css|postcss|pcss)$/);
81
+ chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_PLUGIN).use(__WEBPACK_EXTERNAL_MODULE_vue_loader__.VueLoaderPlugin);
82
+ });
83
+ applySplitChunksRule(api, options.splitChunks);
89
84
  }
90
- return merged;
91
- });
92
- api.modifyBundlerChain(async (chain, { CHAIN_ID }) => {
93
- chain.resolve.extensions.add(".vue");
94
- const userLoaderOptions = options.vueLoaderOptions ?? {};
95
- const compilerOptions = {
96
- preserveWhitespace: false,
97
- ...userLoaderOptions.compilerOptions
98
- };
99
- const vueLoaderOptions = {
100
- experimentalInlineMatchResource: true,
101
- ...userLoaderOptions,
102
- compilerOptions
103
- };
104
- chain.module.rule(CHAIN_ID.RULE.VUE).test(VUE_REGEXP).use(CHAIN_ID.USE.VUE).loader(__require.resolve("vue-loader")).options(vueLoaderOptions);
105
- chain.module.rule(CHAIN_ID.RULE.CSS).test(/\.(?:css|postcss|pcss)$/);
106
- chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_PLUGIN).use(VueLoaderPlugin);
107
- });
108
- applySplitChunksRule(api, options.splitChunks);
109
- }
110
- };
85
+ };
111
86
  }
112
- export {
113
- PLUGIN_VUE_NAME,
114
- pluginVue
115
- };
87
+ export { PLUGIN_VUE_NAME, pluginVue };
@@ -1,3 +1,3 @@
1
1
  import type { RsbuildPluginAPI } from '@rsbuild/core';
2
- import type { SplitVueChunkOptions } from '.';
2
+ import type { SplitVueChunkOptions } from './index.js';
3
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": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Vue 3 plugin of Rsbuild",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "repository": {
@@ -12,26 +12,25 @@
12
12
  "type": "module",
13
13
  "exports": {
14
14
  ".": {
15
- "types": "./dist-types/index.d.ts",
15
+ "types": "./dist/index.d.ts",
16
16
  "import": "./dist/index.js",
17
17
  "require": "./dist/index.cjs"
18
18
  }
19
19
  },
20
20
  "main": "./dist/index.cjs",
21
- "types": "./dist-types/index.d.ts",
21
+ "types": "./dist/index.d.ts",
22
22
  "files": [
23
- "dist",
24
- "dist-types"
23
+ "dist"
25
24
  ],
26
25
  "dependencies": {
27
26
  "vue-loader": "^17.4.2",
28
- "webpack": "^5.94.0"
27
+ "webpack": "^5.95.0"
29
28
  },
30
29
  "devDependencies": {
31
- "typescript": "^5.5.2",
32
- "vue": "^3.5.3",
33
- "webpack": "^5.94.0",
34
- "@rsbuild/core": "1.0.1",
30
+ "typescript": "^5.6.3",
31
+ "vue": "^3.5.12",
32
+ "webpack": "^5.95.0",
33
+ "@rsbuild/core": "1.0.14",
35
34
  "@scripts/test-helper": "1.0.1"
36
35
  },
37
36
  "peerDependencies": {
@@ -43,7 +42,7 @@
43
42
  "registry": "https://registry.npmjs.org/"
44
43
  },
45
44
  "scripts": {
46
- "build": "modern build",
47
- "dev": "modern build --watch"
45
+ "build": "rslib build",
46
+ "dev": "rslib build --watch"
48
47
  }
49
48
  }
@@ -1 +0,0 @@
1
- {"//":"This file is for making TypeScript work with moduleResolution node16+.","version":"1.0.0"}
File without changes