@rsbuild/plugin-vue 1.0.1 → 1.0.3

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,126 @@
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
- }
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 = (api, options = {
43
+ vue: true,
44
+ router: true
45
+ })=>{
46
+ api.modifyBundlerChain((chain, { environment })=>{
47
+ const { config } = environment;
48
+ if ('split-by-experience' !== config.performance.chunkSplit.strategy) return;
49
+ const currentConfig = chain.optimization.splitChunks.values();
50
+ if (!isPlainObject(currentConfig)) return;
51
+ const extraGroups = {};
52
+ if (options.vue) extraGroups.vue = {
53
+ name: 'lib-vue',
54
+ test: /node_modules[\\/](?:vue|vue-loader|@vue[\\/]shared|@vue[\\/]reactivity|@vue[\\/]runtime-dom|@vue[\\/]runtime-core)[\\/]/,
55
+ priority: 0
56
+ };
57
+ if (options.router) extraGroups.router = {
58
+ name: 'lib-router',
59
+ test: /node_modules[\\/]vue-router[\\/]/,
60
+ priority: 0
61
+ };
62
+ if (!Object.keys(extraGroups).length) return;
63
+ chain.optimization.splitChunks({
64
+ ...currentConfig,
65
+ cacheGroups: {
66
+ ...currentConfig.cacheGroups,
67
+ ...extraGroups
68
+ }
69
+ });
78
70
  });
79
- });
80
71
  };
81
-
82
- // src/index.ts
83
- var PLUGIN_VUE_NAME = "rsbuild:vue";
72
+ const src_require = (0, external_node_module_namespaceObject.createRequire)(/*#__PURE__*/ function() {
73
+ 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;
74
+ }());
75
+ const PLUGIN_VUE_NAME = 'rsbuild:vue';
84
76
  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
- }
100
- };
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");
106
- }
107
- return CSS_MODULES_REGEX.test(path);
108
- };
77
+ return {
78
+ name: PLUGIN_VUE_NAME,
79
+ setup (api) {
80
+ const VUE_REGEXP = /\.vue$/;
81
+ const CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
82
+ api.modifyEnvironmentConfig((config, { mergeEnvironmentConfig })=>{
83
+ const extraConfig = {
84
+ source: {
85
+ define: {
86
+ // https://link.vuejs.org/feature-flags
87
+ __VUE_OPTIONS_API__: true,
88
+ __VUE_PROD_DEVTOOLS__: false,
89
+ __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false
90
+ }
91
+ }
92
+ };
93
+ const merged = mergeEnvironmentConfig(extraConfig, config);
94
+ // Support `<style module>` in Vue SFC
95
+ if (true === merged.output.cssModules.auto) merged.output.cssModules.auto = (path, query)=>{
96
+ if (VUE_REGEXP.test(path)) return query.includes('type=style') && query.includes('module=true');
97
+ return CSS_MODULES_REGEX.test(path);
98
+ };
99
+ return merged;
100
+ });
101
+ api.modifyBundlerChain(async (chain, { CHAIN_ID })=>{
102
+ chain.resolve.extensions.add('.vue');
103
+ const userLoaderOptions = options.vueLoaderOptions ?? {};
104
+ const compilerOptions = {
105
+ preserveWhitespace: false,
106
+ ...userLoaderOptions.compilerOptions
107
+ };
108
+ const vueLoaderOptions = {
109
+ experimentalInlineMatchResource: true,
110
+ ...userLoaderOptions,
111
+ compilerOptions
112
+ };
113
+ chain.module.rule(CHAIN_ID.RULE.VUE).test(VUE_REGEXP).use(CHAIN_ID.USE.VUE).loader(src_require.resolve('vue-loader')).options(vueLoaderOptions);
114
+ // Support for lang="postcss" and lang="pcss" in SFC
115
+ chain.module.rule(CHAIN_ID.RULE.CSS).test(/\.(?:css|postcss|pcss)$/);
116
+ chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_PLUGIN).use(external_vue_loader_namespaceObject.VueLoaderPlugin);
117
+ });
118
+ applySplitChunksRule(api, options.splitChunks);
109
119
  }
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
- };
120
+ };
131
121
  }
132
- // Annotate the CommonJS export names for ESM import in node:
133
- 0 && (module.exports = {
134
- PLUGIN_VUE_NAME,
135
- pluginVue
122
+ var __webpack_export_target__ = exports;
123
+ for(var i in __webpack_exports__)__webpack_export_target__[i] = __webpack_exports__[i];
124
+ if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
125
+ value: true
136
126
  });
package/dist/index.js CHANGED
@@ -1,115 +1,82 @@
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
- }
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 = (api, options = {
5
+ vue: true,
6
+ router: true
7
+ })=>{
8
+ api.modifyBundlerChain((chain, { environment })=>{
9
+ const { config } = environment;
10
+ if ('split-by-experience' !== config.performance.chunkSplit.strategy) return;
11
+ const currentConfig = chain.optimization.splitChunks.values();
12
+ if (!isPlainObject(currentConfig)) return;
13
+ const extraGroups = {};
14
+ if (options.vue) extraGroups.vue = {
15
+ name: 'lib-vue',
16
+ test: /node_modules[\\/](?:vue|vue-loader|@vue[\\/]shared|@vue[\\/]reactivity|@vue[\\/]runtime-dom|@vue[\\/]runtime-core)[\\/]/,
17
+ priority: 0
18
+ };
19
+ if (options.router) extraGroups.router = {
20
+ name: 'lib-router',
21
+ test: /node_modules[\\/]vue-router[\\/]/,
22
+ priority: 0
23
+ };
24
+ if (!Object.keys(extraGroups).length) return;
25
+ chain.optimization.splitChunks({
26
+ ...currentConfig,
27
+ cacheGroups: {
28
+ ...currentConfig.cacheGroups,
29
+ ...extraGroups
30
+ }
31
+ });
58
32
  });
59
- });
60
33
  };
61
-
62
- // src/index.ts
63
- var PLUGIN_VUE_NAME = "rsbuild:vue";
34
+ const src_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module__.createRequire)(import.meta.url);
35
+ const PLUGIN_VUE_NAME = 'rsbuild:vue';
64
36
  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
- }
80
- };
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");
86
- }
87
- return CSS_MODULES_REGEX.test(path2);
88
- };
37
+ return {
38
+ name: PLUGIN_VUE_NAME,
39
+ setup (api) {
40
+ const VUE_REGEXP = /\.vue$/;
41
+ const CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
42
+ api.modifyEnvironmentConfig((config, { mergeEnvironmentConfig })=>{
43
+ const extraConfig = {
44
+ source: {
45
+ define: {
46
+ // https://link.vuejs.org/feature-flags
47
+ __VUE_OPTIONS_API__: true,
48
+ __VUE_PROD_DEVTOOLS__: false,
49
+ __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false
50
+ }
51
+ }
52
+ };
53
+ const merged = mergeEnvironmentConfig(extraConfig, config);
54
+ // Support `<style module>` in Vue SFC
55
+ if (true === merged.output.cssModules.auto) merged.output.cssModules.auto = (path, query)=>{
56
+ if (VUE_REGEXP.test(path)) return query.includes('type=style') && query.includes('module=true');
57
+ return CSS_MODULES_REGEX.test(path);
58
+ };
59
+ return merged;
60
+ });
61
+ api.modifyBundlerChain(async (chain, { CHAIN_ID })=>{
62
+ chain.resolve.extensions.add('.vue');
63
+ const userLoaderOptions = options.vueLoaderOptions ?? {};
64
+ const compilerOptions = {
65
+ preserveWhitespace: false,
66
+ ...userLoaderOptions.compilerOptions
67
+ };
68
+ const vueLoaderOptions = {
69
+ experimentalInlineMatchResource: true,
70
+ ...userLoaderOptions,
71
+ compilerOptions
72
+ };
73
+ chain.module.rule(CHAIN_ID.RULE.VUE).test(VUE_REGEXP).use(CHAIN_ID.USE.VUE).loader(src_require.resolve('vue-loader')).options(vueLoaderOptions);
74
+ // Support for lang="postcss" and lang="pcss" in SFC
75
+ chain.module.rule(CHAIN_ID.RULE.CSS).test(/\.(?:css|postcss|pcss)$/);
76
+ chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_PLUGIN).use(__WEBPACK_EXTERNAL_MODULE_vue_loader__.VueLoaderPlugin);
77
+ });
78
+ applySplitChunksRule(api, options.splitChunks);
89
79
  }
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
- };
80
+ };
111
81
  }
112
- export {
113
- PLUGIN_VUE_NAME,
114
- pluginVue
115
- };
82
+ 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.3",
4
4
  "description": "Vue 3 plugin of Rsbuild",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "repository": {
@@ -12,30 +12,29 @@
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.19",
35
34
  "@scripts/test-helper": "1.0.1"
36
35
  },
37
36
  "peerDependencies": {
38
- "@rsbuild/core": "1.x || ^1.0.1-rc.0"
37
+ "@rsbuild/core": "1.x"
39
38
  },
40
39
  "publishConfig": {
41
40
  "access": "public",
@@ -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