@rsbuild/plugin-vue2 0.0.0-next-20240514150515 → 0.0.0-next-20240528072128

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
@@ -38,7 +38,6 @@ __export(src_exports, {
38
38
  pluginVue2: () => pluginVue2
39
39
  });
40
40
  module.exports = __toCommonJS(src_exports);
41
- var import_shared2 = require("@rsbuild/shared");
42
41
  var import_vue_loader = require("vue-loader");
43
42
 
44
43
  // src/VueLoader15PitchFixPlugin.ts
@@ -121,21 +120,39 @@ function pluginVue2(options = {}) {
121
120
  return {
122
121
  name: "rsbuild:vue2",
123
122
  setup(api) {
123
+ const VUE_REGEXP = /\.vue$/;
124
+ const CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
125
+ api.modifyRsbuildConfig((config) => {
126
+ var _a;
127
+ config.output || (config.output = {});
128
+ (_a = config.output).cssModules || (_a.cssModules = {});
129
+ if (config.output.cssModules.auto === true) {
130
+ config.output.cssModules.auto = (path, query) => {
131
+ if (VUE_REGEXP.test(path)) {
132
+ return query.includes("type=style") && query.includes("module=true");
133
+ }
134
+ return CSS_MODULES_REGEX.test(path);
135
+ };
136
+ }
137
+ return config;
138
+ });
124
139
  api.modifyBundlerChain((chain, { CHAIN_ID }) => {
125
140
  chain.resolve.extensions.add(".vue");
126
141
  if (!chain.resolve.alias.get("vue$")) {
127
142
  chain.resolve.alias.set("vue$", "vue/dist/vue.runtime.esm.js");
128
143
  }
129
- const vueLoaderOptions = (0, import_shared2.deepmerge)(
130
- {
131
- compilerOptions: {
132
- preserveWhitespace: false
133
- },
134
- experimentalInlineMatchResource: true
135
- },
136
- options.vueLoaderOptions ?? {}
137
- );
138
- chain.module.rule(CHAIN_ID.RULE.VUE).test(/\.vue$/).use(CHAIN_ID.USE.VUE).loader(require.resolve("vue-loader")).options(vueLoaderOptions);
144
+ const userLoaderOptions = options.vueLoaderOptions ?? {};
145
+ const compilerOptions = {
146
+ preserveWhitespace: false,
147
+ ...userLoaderOptions.compilerOptions
148
+ };
149
+ const vueLoaderOptions = {
150
+ experimentalInlineMatchResource: true,
151
+ ...userLoaderOptions,
152
+ compilerOptions
153
+ };
154
+ chain.module.rule(CHAIN_ID.RULE.VUE).test(VUE_REGEXP).use(CHAIN_ID.USE.VUE).loader(require.resolve("vue-loader")).options(vueLoaderOptions);
155
+ chain.module.rule(CHAIN_ID.RULE.CSS).test(/\.(?:css|postcss|pcss)$/);
139
156
  chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_PLUGIN).use(import_vue_loader.VueLoaderPlugin);
140
157
  chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_15_PITCH_FIX_PLUGIN).use(VueLoader15PitchFixPlugin);
141
158
  });
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import type { RsbuildPlugin } from '@rsbuild/core';
2
- import type { VueLoaderOptions } from 'vue-loader';
3
- export type SplitVueChunkOptions = {
1
+ import { RsbuildPlugin } from '@rsbuild/core';
2
+ import { VueLoaderOptions } from 'vue-loader';
3
+
4
+ type SplitVueChunkOptions = {
4
5
  /**
5
6
  * Whether to enable split chunking for Vue-related dependencies (e.g., vue, vue-loader).
6
7
  * @default true
@@ -12,7 +13,7 @@ export type SplitVueChunkOptions = {
12
13
  */
13
14
  router?: boolean;
14
15
  };
15
- export type PluginVueOptions = {
16
+ type PluginVueOptions = {
16
17
  /**
17
18
  * Options passed to `vue-loader`.
18
19
  * @see https://vue-loader.vuejs.org/
@@ -23,4 +24,6 @@ export type PluginVueOptions = {
23
24
  */
24
25
  splitChunks?: SplitVueChunkOptions;
25
26
  };
26
- export declare function pluginVue2(options?: PluginVueOptions): RsbuildPlugin;
27
+ declare function pluginVue2(options?: PluginVueOptions): RsbuildPlugin;
28
+
29
+ export { type PluginVueOptions, type SplitVueChunkOptions, pluginVue2 };
package/dist/index.js CHANGED
@@ -15,12 +15,11 @@ var __publicField = (obj, key, value) => {
15
15
  return value;
16
16
  };
17
17
 
18
- // ../../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
18
+ // ../../node_modules/.pnpm/@modern-js+module-tools@2.50.0_eslint@9.3.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js
19
19
  import { fileURLToPath } from "url";
20
20
  import path from "path";
21
21
 
22
22
  // src/index.ts
23
- import { deepmerge } from "@rsbuild/shared";
24
23
  import { VueLoaderPlugin } from "vue-loader";
25
24
 
26
25
  // src/VueLoader15PitchFixPlugin.ts
@@ -63,10 +62,7 @@ var VueLoader15PitchFixPlugin = class {
63
62
  };
64
63
 
65
64
  // src/splitChunks.ts
66
- import {
67
- createCacheGroups,
68
- isPlainObject
69
- } from "@rsbuild/shared";
65
+ import { createCacheGroups, isPlainObject } from "@rsbuild/shared";
70
66
  var applySplitChunksRule = (api, options = {
71
67
  vue: true,
72
68
  router: true
@@ -106,21 +102,39 @@ function pluginVue2(options = {}) {
106
102
  return {
107
103
  name: "rsbuild:vue2",
108
104
  setup(api) {
105
+ const VUE_REGEXP = /\.vue$/;
106
+ const CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
107
+ api.modifyRsbuildConfig((config) => {
108
+ var _a;
109
+ config.output || (config.output = {});
110
+ (_a = config.output).cssModules || (_a.cssModules = {});
111
+ if (config.output.cssModules.auto === true) {
112
+ config.output.cssModules.auto = (path2, query) => {
113
+ if (VUE_REGEXP.test(path2)) {
114
+ return query.includes("type=style") && query.includes("module=true");
115
+ }
116
+ return CSS_MODULES_REGEX.test(path2);
117
+ };
118
+ }
119
+ return config;
120
+ });
109
121
  api.modifyBundlerChain((chain, { CHAIN_ID }) => {
110
122
  chain.resolve.extensions.add(".vue");
111
123
  if (!chain.resolve.alias.get("vue$")) {
112
124
  chain.resolve.alias.set("vue$", "vue/dist/vue.runtime.esm.js");
113
125
  }
114
- const vueLoaderOptions = deepmerge(
115
- {
116
- compilerOptions: {
117
- preserveWhitespace: false
118
- },
119
- experimentalInlineMatchResource: true
120
- },
121
- options.vueLoaderOptions ?? {}
122
- );
123
- chain.module.rule(CHAIN_ID.RULE.VUE).test(/\.vue$/).use(CHAIN_ID.USE.VUE).loader(__require.resolve("vue-loader")).options(vueLoaderOptions);
126
+ const userLoaderOptions = options.vueLoaderOptions ?? {};
127
+ const compilerOptions = {
128
+ preserveWhitespace: false,
129
+ ...userLoaderOptions.compilerOptions
130
+ };
131
+ const vueLoaderOptions = {
132
+ experimentalInlineMatchResource: true,
133
+ ...userLoaderOptions,
134
+ compilerOptions
135
+ };
136
+ chain.module.rule(CHAIN_ID.RULE.VUE).test(VUE_REGEXP).use(CHAIN_ID.USE.VUE).loader(__require.resolve("vue-loader")).options(vueLoaderOptions);
137
+ chain.module.rule(CHAIN_ID.RULE.CSS).test(/\.(?:css|postcss|pcss)$/);
124
138
  chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_PLUGIN).use(VueLoaderPlugin);
125
139
  chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_15_PITCH_FIX_PLUGIN).use(VueLoader15PitchFixPlugin);
126
140
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-vue2",
3
- "version": "0.0.0-next-20240514150515",
3
+ "version": "0.0.0-next-20240528072128",
4
4
  "description": "Vue 2 plugin of Rsbuild",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "repository": {
@@ -25,16 +25,16 @@
25
25
  "dependencies": {
26
26
  "vue-loader": "^15.11.1",
27
27
  "webpack": "^5.91.0",
28
- "@rsbuild/shared": "0.0.0-next-20240514150515"
28
+ "@rsbuild/shared": "0.0.0-next-20240528072128"
29
29
  },
30
30
  "devDependencies": {
31
31
  "typescript": "^5.4.2",
32
32
  "webpack": "^5.91.0",
33
- "@rsbuild/core": "0.0.0-next-20240514150515",
34
- "@scripts/test-helper": "0.0.0-next-20240514150515"
33
+ "@rsbuild/core": "0.0.0-next-20240528072128",
34
+ "@scripts/test-helper": "0.0.0-next-20240528072128"
35
35
  },
36
36
  "peerDependencies": {
37
- "@rsbuild/core": "0.0.0-next-20240514150515"
37
+ "@rsbuild/core": "0.0.0-next-20240528072128"
38
38
  },
39
39
  "publishConfig": {
40
40
  "access": "public",
@@ -1,8 +0,0 @@
1
- import type { Rspack } from '@rsbuild/shared';
2
- /**
3
- * this plugin is a quick fix for issue https://github.com/web-infra-dev/rsbuild/issues/2093
4
- */
5
- export declare class VueLoader15PitchFixPlugin implements Rspack.RspackPluginInstance {
6
- readonly name = "VueLoader15PitchFixPlugin";
7
- apply(compiler: Rspack.Compiler): void;
8
- }
@@ -1,3 +0,0 @@
1
- import type { RsbuildPluginAPI } from '@rsbuild/core';
2
- import type { SplitVueChunkOptions } from '.';
3
- export declare const applySplitChunksRule: (api: RsbuildPluginAPI, options?: SplitVueChunkOptions) => void;