@rsbuild/plugin-source-build 1.0.0-alpha.0 → 1.0.0-alpha.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.cjs +33 -15
- package/dist/index.js +33 -15
- package/dist/types/index.d.ts +5 -0
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -7737,16 +7737,34 @@ function pluginSourceBuild(options) {
|
|
|
7737
7737
|
}
|
|
7738
7738
|
}
|
|
7739
7739
|
});
|
|
7740
|
-
const getReferences = async (tsconfigPath) => {
|
|
7741
|
-
const
|
|
7742
|
-
|
|
7743
|
-
|
|
7744
|
-
const
|
|
7745
|
-
|
|
7746
|
-
|
|
7747
|
-
|
|
7740
|
+
const getReferences = async (tsconfigPath, rspackReferences) => {
|
|
7741
|
+
const { default: json52 } = await import("json5");
|
|
7742
|
+
const references = /* @__PURE__ */ new Set();
|
|
7743
|
+
for (const project of projects) {
|
|
7744
|
+
const filePath = import_node_path8.default.join(project.dir, "tsconfig.json");
|
|
7745
|
+
if (import_node_fs6.default.existsSync(filePath)) {
|
|
7746
|
+
references.add(filePath);
|
|
7747
|
+
}
|
|
7748
|
+
}
|
|
7749
|
+
const tsconfig = json52.parse(
|
|
7750
|
+
import_node_fs6.default.readFileSync(tsconfigPath, "utf-8")
|
|
7751
|
+
);
|
|
7752
|
+
const userReferences = [
|
|
7753
|
+
...Array.isArray(rspackReferences) ? rspackReferences : [],
|
|
7754
|
+
...tsconfig.references ? tsconfig.references.map((item) => item.path).filter(Boolean) : []
|
|
7755
|
+
];
|
|
7756
|
+
if (userReferences.length) {
|
|
7757
|
+
const baseDir = import_node_path8.default.dirname(tsconfigPath);
|
|
7758
|
+
for (const item of userReferences) {
|
|
7759
|
+
if (!item) {
|
|
7760
|
+
continue;
|
|
7761
|
+
}
|
|
7762
|
+
const absolutePath = import_node_path8.default.isAbsolute(item) ? item : import_node_path8.default.join(baseDir, item);
|
|
7763
|
+
references.add(absolutePath);
|
|
7764
|
+
}
|
|
7748
7765
|
}
|
|
7749
|
-
|
|
7766
|
+
references.delete(tsconfigPath);
|
|
7767
|
+
return Array.from(references);
|
|
7750
7768
|
};
|
|
7751
7769
|
if (api.context.bundlerType === "rspack") {
|
|
7752
7770
|
api.modifyRspackConfig(async (config, { environment }) => {
|
|
@@ -7757,10 +7775,10 @@ function pluginSourceBuild(options) {
|
|
|
7757
7775
|
config.resolve ||= {};
|
|
7758
7776
|
const { tsConfig = { configFile: tsconfigPath } } = config.resolve;
|
|
7759
7777
|
const configObject = typeof tsConfig === "string" ? { configFile: tsConfig } : tsConfig;
|
|
7760
|
-
const references =
|
|
7761
|
-
|
|
7762
|
-
|
|
7763
|
-
|
|
7778
|
+
const references = await getReferences(
|
|
7779
|
+
tsconfigPath,
|
|
7780
|
+
configObject.references
|
|
7781
|
+
);
|
|
7764
7782
|
config.resolve.tsConfig = {
|
|
7765
7783
|
configFile: configObject?.configFile || tsconfigPath,
|
|
7766
7784
|
references
|
|
@@ -7769,10 +7787,10 @@ function pluginSourceBuild(options) {
|
|
|
7769
7787
|
} else {
|
|
7770
7788
|
api.modifyBundlerChain(async (chain, { CHAIN_ID, environment }) => {
|
|
7771
7789
|
const { TS_CONFIG_PATHS } = CHAIN_ID.RESOLVE_PLUGIN;
|
|
7772
|
-
|
|
7790
|
+
const { tsconfigPath } = environment;
|
|
7791
|
+
if (!chain.resolve.plugins.has(TS_CONFIG_PATHS) || !tsconfigPath) {
|
|
7773
7792
|
return;
|
|
7774
7793
|
}
|
|
7775
|
-
const { tsconfigPath } = environment;
|
|
7776
7794
|
const references = await getReferences(tsconfigPath);
|
|
7777
7795
|
chain.resolve.plugin(TS_CONFIG_PATHS).tap(
|
|
7778
7796
|
(options2) => options2.map((option) => ({
|
package/dist/index.js
CHANGED
|
@@ -7827,16 +7827,34 @@ function pluginSourceBuild(options) {
|
|
|
7827
7827
|
}
|
|
7828
7828
|
}
|
|
7829
7829
|
});
|
|
7830
|
-
const getReferences = async (tsconfigPath) => {
|
|
7831
|
-
const
|
|
7832
|
-
|
|
7833
|
-
|
|
7834
|
-
const
|
|
7835
|
-
|
|
7836
|
-
|
|
7837
|
-
|
|
7830
|
+
const getReferences = async (tsconfigPath, rspackReferences) => {
|
|
7831
|
+
const { default: json52 } = await import("json5");
|
|
7832
|
+
const references = /* @__PURE__ */ new Set();
|
|
7833
|
+
for (const project of projects) {
|
|
7834
|
+
const filePath = path9.join(project.dir, "tsconfig.json");
|
|
7835
|
+
if (fs6.existsSync(filePath)) {
|
|
7836
|
+
references.add(filePath);
|
|
7837
|
+
}
|
|
7838
|
+
}
|
|
7839
|
+
const tsconfig = json52.parse(
|
|
7840
|
+
fs6.readFileSync(tsconfigPath, "utf-8")
|
|
7841
|
+
);
|
|
7842
|
+
const userReferences = [
|
|
7843
|
+
...Array.isArray(rspackReferences) ? rspackReferences : [],
|
|
7844
|
+
...tsconfig.references ? tsconfig.references.map((item) => item.path).filter(Boolean) : []
|
|
7845
|
+
];
|
|
7846
|
+
if (userReferences.length) {
|
|
7847
|
+
const baseDir = path9.dirname(tsconfigPath);
|
|
7848
|
+
for (const item of userReferences) {
|
|
7849
|
+
if (!item) {
|
|
7850
|
+
continue;
|
|
7851
|
+
}
|
|
7852
|
+
const absolutePath = path9.isAbsolute(item) ? item : path9.join(baseDir, item);
|
|
7853
|
+
references.add(absolutePath);
|
|
7854
|
+
}
|
|
7838
7855
|
}
|
|
7839
|
-
|
|
7856
|
+
references.delete(tsconfigPath);
|
|
7857
|
+
return Array.from(references);
|
|
7840
7858
|
};
|
|
7841
7859
|
if (api.context.bundlerType === "rspack") {
|
|
7842
7860
|
api.modifyRspackConfig(async (config, { environment }) => {
|
|
@@ -7847,10 +7865,10 @@ function pluginSourceBuild(options) {
|
|
|
7847
7865
|
config.resolve ||= {};
|
|
7848
7866
|
const { tsConfig = { configFile: tsconfigPath } } = config.resolve;
|
|
7849
7867
|
const configObject = typeof tsConfig === "string" ? { configFile: tsConfig } : tsConfig;
|
|
7850
|
-
const references =
|
|
7851
|
-
|
|
7852
|
-
|
|
7853
|
-
|
|
7868
|
+
const references = await getReferences(
|
|
7869
|
+
tsconfigPath,
|
|
7870
|
+
configObject.references
|
|
7871
|
+
);
|
|
7854
7872
|
config.resolve.tsConfig = {
|
|
7855
7873
|
configFile: configObject?.configFile || tsconfigPath,
|
|
7856
7874
|
references
|
|
@@ -7859,10 +7877,10 @@ function pluginSourceBuild(options) {
|
|
|
7859
7877
|
} else {
|
|
7860
7878
|
api.modifyBundlerChain(async (chain, { CHAIN_ID, environment }) => {
|
|
7861
7879
|
const { TS_CONFIG_PATHS } = CHAIN_ID.RESOLVE_PLUGIN;
|
|
7862
|
-
|
|
7880
|
+
const { tsconfigPath } = environment;
|
|
7881
|
+
if (!chain.resolve.plugins.has(TS_CONFIG_PATHS) || !tsconfigPath) {
|
|
7863
7882
|
return;
|
|
7864
7883
|
}
|
|
7865
|
-
const { tsconfigPath } = environment;
|
|
7866
7884
|
const references = await getReferences(tsconfigPath);
|
|
7867
7885
|
chain.resolve.plugin(TS_CONFIG_PATHS).tap(
|
|
7868
7886
|
(options2) => options2.map((option) => ({
|
package/dist/types/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-source-build",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.2",
|
|
4
4
|
"description": "Source build plugin of Rsbuild",
|
|
5
5
|
"homepage": "https://rsbuild.dev",
|
|
6
6
|
"repository": {
|
|
@@ -25,17 +25,17 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"fast-glob": "^3.3.2",
|
|
27
27
|
"json5": "^2.2.3",
|
|
28
|
-
"@rsbuild/shared": "1.0.0-alpha.
|
|
28
|
+
"@rsbuild/shared": "1.0.0-alpha.2"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"typescript": "^5.5.2",
|
|
32
32
|
"yaml": "^2.4.5",
|
|
33
|
-
"@rsbuild/core": "1.0.0-alpha.
|
|
34
|
-
"@rsbuild/plugin-babel": "1.0.0-alpha.
|
|
35
|
-
"@scripts/test-helper": "1.0.0-alpha.
|
|
33
|
+
"@rsbuild/core": "1.0.0-alpha.2",
|
|
34
|
+
"@rsbuild/plugin-babel": "1.0.0-alpha.2",
|
|
35
|
+
"@scripts/test-helper": "1.0.0-alpha.2"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@rsbuild/core": "^1.0.0-alpha.
|
|
38
|
+
"@rsbuild/core": "^1.0.0-alpha.2"
|
|
39
39
|
},
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public",
|