@rsbuild/plugin-styled-components 0.3.0 → 0.3.1

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
@@ -27,7 +27,7 @@ var import_shared = require("@rsbuild/shared");
27
27
  var pluginStyledComponents = (userConfig = {}) => ({
28
28
  name: "rsbuild:styled-components",
29
29
  setup(api) {
30
- api.modifyBundlerChain(async (chain, { CHAIN_ID, isProd }) => {
30
+ api.modifyBundlerChain(async (chain, { isProd }) => {
31
31
  const { bundlerType } = api.context;
32
32
  if (bundlerType === "webpack") {
33
33
  return;
@@ -40,16 +40,12 @@ var pluginStyledComponents = (userConfig = {}) => ({
40
40
  if (!styledComponentsOptions) {
41
41
  return;
42
42
  }
43
- [CHAIN_ID.RULE.JS, CHAIN_ID.RULE.JS_DATA_URI].forEach((ruleId) => {
44
- if (chain.module.rules.has(ruleId)) {
45
- const rule = chain.module.rule(ruleId);
46
- if (rule.uses.has(CHAIN_ID.USE.SWC)) {
47
- rule.use(CHAIN_ID.USE.SWC).tap((options) => {
48
- options.rspackExperiments ?? (options.rspackExperiments = {});
49
- options.rspackExperiments.styledComponents = styledComponentsOptions;
50
- return options;
51
- });
52
- }
43
+ (0, import_shared.modifySwcLoaderOptions)({
44
+ chain,
45
+ modifier: (options) => {
46
+ options.rspackExperiments ?? (options.rspackExperiments = {});
47
+ options.rspackExperiments.styledComponents = styledComponentsOptions;
48
+ return options;
53
49
  }
54
50
  });
55
51
  });
package/dist/index.mjs CHANGED
@@ -10,12 +10,13 @@ global.require = createRequire(import.meta.url);
10
10
  import {
11
11
  isServerTarget,
12
12
  mergeChainedOptions,
13
+ modifySwcLoaderOptions,
13
14
  getDefaultStyledComponentsConfig
14
15
  } from "@rsbuild/shared";
15
16
  var pluginStyledComponents = (userConfig = {}) => ({
16
17
  name: "rsbuild:styled-components",
17
18
  setup(api) {
18
- api.modifyBundlerChain(async (chain, { CHAIN_ID, isProd }) => {
19
+ api.modifyBundlerChain(async (chain, { isProd }) => {
19
20
  const { bundlerType } = api.context;
20
21
  if (bundlerType === "webpack") {
21
22
  return;
@@ -28,16 +29,12 @@ var pluginStyledComponents = (userConfig = {}) => ({
28
29
  if (!styledComponentsOptions) {
29
30
  return;
30
31
  }
31
- [CHAIN_ID.RULE.JS, CHAIN_ID.RULE.JS_DATA_URI].forEach((ruleId) => {
32
- if (chain.module.rules.has(ruleId)) {
33
- const rule = chain.module.rule(ruleId);
34
- if (rule.uses.has(CHAIN_ID.USE.SWC)) {
35
- rule.use(CHAIN_ID.USE.SWC).tap((options) => {
36
- options.rspackExperiments ?? (options.rspackExperiments = {});
37
- options.rspackExperiments.styledComponents = styledComponentsOptions;
38
- return options;
39
- });
40
- }
32
+ modifySwcLoaderOptions({
33
+ chain,
34
+ modifier: (options) => {
35
+ options.rspackExperiments ?? (options.rspackExperiments = {});
36
+ options.rspackExperiments.styledComponents = styledComponentsOptions;
37
+ return options;
41
38
  }
42
39
  });
43
40
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-styled-components",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "styled-components plugin for Rsbuild",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,13 +22,13 @@
22
22
  "dist"
23
23
  ],
24
24
  "dependencies": {
25
- "@rsbuild/shared": "0.3.0"
25
+ "@rsbuild/shared": "0.3.1"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/node": "16.x",
29
29
  "typescript": "^5.3.0",
30
- "@rsbuild/test-helper": "0.3.0",
31
- "@rsbuild/core": "0.3.0"
30
+ "@scripts/test-helper": "1.0.0",
31
+ "@rsbuild/core": "0.3.1"
32
32
  },
33
33
  "publishConfig": {
34
34
  "access": "public",