@rsbuild/plugin-solid 0.2.0 → 0.2.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.js CHANGED
@@ -33,35 +33,33 @@ __export(src_exports, {
33
33
  pluginSolid: () => pluginSolid
34
34
  });
35
35
  module.exports = __toCommonJS(src_exports);
36
+ var import_plugin_babel = require("@rsbuild/plugin-babel");
36
37
  function pluginSolid(options = {}) {
37
38
  return {
38
39
  name: "rsbuild:solid",
39
40
  pre: ["rsbuild:babel"],
40
41
  setup(api) {
41
42
  api.modifyBundlerChain(async (chain, { CHAIN_ID, isProd }) => {
42
- [CHAIN_ID.RULE.JS, CHAIN_ID.RULE.JS_DATA_URI].forEach((ruleId) => {
43
- if (chain.module.rules.has(ruleId)) {
44
- const rsbuildConfig = api.getNormalizedConfig();
45
- const rule = chain.module.rule(ruleId);
46
- if (rule.uses.has(CHAIN_ID.USE.BABEL)) {
47
- rule.use(CHAIN_ID.USE.BABEL).tap((babelConfig) => {
48
- babelConfig.presets ?? (babelConfig.presets = []);
49
- babelConfig.presets.push([
50
- require.resolve("babel-preset-solid"),
51
- options.solidPresetOptions || {}
52
- ]);
53
- if (!isProd && rsbuildConfig.dev.hmr) {
54
- babelConfig.plugins ?? (babelConfig.plugins = []);
55
- babelConfig.plugins.push([
56
- require.resolve("solid-refresh/babel")
57
- ]);
58
- chain.resolve.alias.merge({
59
- "solid-refresh": require.resolve("solid-refresh/dist/solid-refresh.mjs")
60
- });
61
- }
62
- return babelConfig;
43
+ const rsbuildConfig = api.getNormalizedConfig();
44
+ (0, import_plugin_babel.modifyBabelLoaderOptions)({
45
+ chain,
46
+ CHAIN_ID,
47
+ modifier: (babelOptions) => {
48
+ babelOptions.presets ?? (babelOptions.presets = []);
49
+ babelOptions.presets.push([
50
+ require.resolve("babel-preset-solid"),
51
+ options.solidPresetOptions || {}
52
+ ]);
53
+ if (!isProd && rsbuildConfig.dev.hmr) {
54
+ babelOptions.plugins ?? (babelOptions.plugins = []);
55
+ babelOptions.plugins.push([
56
+ require.resolve("solid-refresh/babel")
57
+ ]);
58
+ chain.resolve.alias.merge({
59
+ "solid-refresh": require.resolve("solid-refresh/dist/solid-refresh.mjs")
63
60
  });
64
61
  }
62
+ return babelOptions;
65
63
  }
66
64
  });
67
65
  });
package/dist/index.mjs CHANGED
@@ -15,37 +15,35 @@ import { createRequire } from "module";
15
15
  global.require = createRequire(import.meta.url);
16
16
 
17
17
  // src/index.ts
18
+ import { modifyBabelLoaderOptions } from "@rsbuild/plugin-babel";
18
19
  function pluginSolid(options = {}) {
19
20
  return {
20
21
  name: "rsbuild:solid",
21
22
  pre: ["rsbuild:babel"],
22
23
  setup(api) {
23
24
  api.modifyBundlerChain(async (chain, { CHAIN_ID, isProd }) => {
24
- [CHAIN_ID.RULE.JS, CHAIN_ID.RULE.JS_DATA_URI].forEach((ruleId) => {
25
- if (chain.module.rules.has(ruleId)) {
26
- const rsbuildConfig = api.getNormalizedConfig();
27
- const rule = chain.module.rule(ruleId);
28
- if (rule.uses.has(CHAIN_ID.USE.BABEL)) {
29
- rule.use(CHAIN_ID.USE.BABEL).tap((babelConfig) => {
30
- babelConfig.presets ?? (babelConfig.presets = []);
31
- babelConfig.presets.push([
32
- __require.resolve("babel-preset-solid"),
33
- options.solidPresetOptions || {}
34
- ]);
35
- if (!isProd && rsbuildConfig.dev.hmr) {
36
- babelConfig.plugins ?? (babelConfig.plugins = []);
37
- babelConfig.plugins.push([
38
- __require.resolve("solid-refresh/babel")
39
- ]);
40
- chain.resolve.alias.merge({
41
- "solid-refresh": __require.resolve(
42
- "solid-refresh/dist/solid-refresh.mjs"
43
- )
44
- });
45
- }
46
- return babelConfig;
25
+ const rsbuildConfig = api.getNormalizedConfig();
26
+ modifyBabelLoaderOptions({
27
+ chain,
28
+ CHAIN_ID,
29
+ modifier: (babelOptions) => {
30
+ babelOptions.presets ?? (babelOptions.presets = []);
31
+ babelOptions.presets.push([
32
+ __require.resolve("babel-preset-solid"),
33
+ options.solidPresetOptions || {}
34
+ ]);
35
+ if (!isProd && rsbuildConfig.dev.hmr) {
36
+ babelOptions.plugins ?? (babelOptions.plugins = []);
37
+ babelOptions.plugins.push([
38
+ __require.resolve("solid-refresh/babel")
39
+ ]);
40
+ chain.resolve.alias.merge({
41
+ "solid-refresh": __require.resolve(
42
+ "solid-refresh/dist/solid-refresh.mjs"
43
+ )
47
44
  });
48
45
  }
46
+ return babelOptions;
49
47
  }
50
48
  });
51
49
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-solid",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Solid plugin for Rsbuild",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "repository": {
@@ -25,15 +25,15 @@
25
25
  "dependencies": {
26
26
  "babel-preset-solid": "^1.8.6",
27
27
  "solid-refresh": "^0.6.0",
28
- "@rsbuild/shared": "0.2.0"
28
+ "@rsbuild/plugin-babel": "0.2.2",
29
+ "@rsbuild/shared": "0.2.2"
29
30
  },
30
31
  "devDependencies": {
31
32
  "@types/babel__core": "^7.20.3",
32
33
  "typescript": "^5.3.0",
33
- "@rsbuild/core": "0.2.0",
34
- "@rsbuild/plugin-babel": "0.2.0",
35
- "@rsbuild/test-helper": "0.2.0",
36
- "@rsbuild/webpack": "0.2.0"
34
+ "@rsbuild/core": "0.2.2",
35
+ "@rsbuild/test-helper": "0.2.2",
36
+ "@rsbuild/webpack": "0.2.2"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "@rsbuild/core": "0.x"