@rsbuild/plugin-source-build 0.2.17 → 0.3.0

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/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # Rsbuild
6
6
 
7
- Unleash the power of Rspack with the out-of-the-box build tool.
7
+ The Rspack-based build tool. It's fast, out-of-the-box and extensible.
8
8
 
9
9
  ## Documentation
10
10
 
package/dist/index.d.ts CHANGED
@@ -12,6 +12,11 @@ interface PluginSourceBuildOptions {
12
12
  * @default 'source''
13
13
  */
14
14
  sourceField?: string;
15
+ /**
16
+ * Whether to read source code or output code first.
17
+ * @default 'source'
18
+ */
19
+ resolvePriority?: 'source' | 'output';
15
20
  projectName?: string;
16
21
  extraMonorepoStrategies?: ExtraMonorepoStrategies;
17
22
  }
package/dist/index.js CHANGED
@@ -52,6 +52,7 @@ function pluginSourceBuild(options) {
52
52
  const {
53
53
  projectName,
54
54
  sourceField = "source",
55
+ resolvePriority = "source",
55
56
  extraMonorepoStrategies
56
57
  } = options ?? {};
57
58
  return {
@@ -83,8 +84,12 @@ function pluginSourceBuild(options) {
83
84
  [CHAIN_ID.RULE.TS, CHAIN_ID.RULE.JS].forEach((ruleId) => {
84
85
  if (chain.module.rules.get(ruleId)) {
85
86
  const rule = chain.module.rule(ruleId);
86
- rule.resolve.mainFields.merge([sourceField, "..."]);
87
+ rule.resolve.mainFields.merge(
88
+ resolvePriority === "source" ? [sourceField, "..."] : ["...", sourceField]
89
+ );
87
90
  rule.resolve.merge({
91
+ // `conditionNames` is not affected by `resolvePriority`.
92
+ // The priority is controlled by the order of fields declared in `exports`.
88
93
  conditionNames: ["...", sourceField]
89
94
  });
90
95
  }
package/dist/index.mjs CHANGED
@@ -27,6 +27,7 @@ function pluginSourceBuild(options) {
27
27
  const {
28
28
  projectName,
29
29
  sourceField = "source",
30
+ resolvePriority = "source",
30
31
  extraMonorepoStrategies
31
32
  } = options ?? {};
32
33
  return {
@@ -58,8 +59,12 @@ function pluginSourceBuild(options) {
58
59
  [CHAIN_ID.RULE.TS, CHAIN_ID.RULE.JS].forEach((ruleId) => {
59
60
  if (chain.module.rules.get(ruleId)) {
60
61
  const rule = chain.module.rule(ruleId);
61
- rule.resolve.mainFields.merge([sourceField, "..."]);
62
+ rule.resolve.mainFields.merge(
63
+ resolvePriority === "source" ? [sourceField, "..."] : ["...", sourceField]
64
+ );
62
65
  rule.resolve.merge({
66
+ // `conditionNames` is not affected by `resolvePriority`.
67
+ // The priority is controlled by the order of fields declared in `exports`.
63
68
  conditionNames: ["...", sourceField]
64
69
  });
65
70
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-source-build",
3
- "version": "0.2.17",
3
+ "version": "0.3.0",
4
4
  "description": "Source build plugin of Rsbuild",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "repository": {
@@ -23,14 +23,15 @@
23
23
  "dist"
24
24
  ],
25
25
  "dependencies": {
26
- "@rsbuild/monorepo-utils": "0.2.17",
27
- "@rsbuild/shared": "0.2.17"
26
+ "@rsbuild/shared": "0.3.0",
27
+ "@rsbuild/monorepo-utils": "0.3.0"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@babel/core": "^7.23.2",
31
31
  "typescript": "^5.3.0",
32
- "@rsbuild/core": "0.2.17",
33
- "@rsbuild/test-helper": "0.2.17"
32
+ "@rsbuild/core": "0.3.0",
33
+ "@rsbuild/plugin-babel": "0.3.0",
34
+ "@rsbuild/test-helper": "0.3.0"
34
35
  },
35
36
  "peerDependencies": {
36
37
  "@rsbuild/core": "0.x"