Skip to content
This repository was archived by the owner on May 3, 2026. It is now read-only.

Commit 812bede

Browse files
committed
build: fixed build distfiles
1 parent 351844f commit 812bede

3 files changed

Lines changed: 42 additions & 4 deletions

File tree

files/empty-project/package.dist.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"unpkg": "tsparticles.empty.template.min.js",
7373
"module": "index.js",
7474
"types": "index.d.ts",
75-
"dependencies": {
75+
"peerDependencies": {
7676
"@tsparticles/engine": "^3.9.1"
7777
}
7878
}

files/empty-project/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
"@swc/core": "^1.15.21",
8787
"@tsparticles/cli": "latest",
8888
"@tsparticles/depcruise-config": "^3.4.4",
89+
"@tsparticles/engine": "^3.9.1",
8990
"@tsparticles/eslint-config": "^3.4.4",
9091
"@tsparticles/prettier-config": "^3.4.4",
9192
"@tsparticles/tsconfig": "^3.4.4",
@@ -105,7 +106,7 @@
105106
"webpack-bundle-analyzer": "^5.3.0",
106107
"webpack-cli": "^7.0.2"
107108
},
108-
"dependencies": {
109+
"peerDependencies": {
109110
"@tsparticles/engine": "^3.9.1"
110111
}
111112
}

src/build/build-distfiles.ts

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,43 @@ import { existsSync } from "node:fs";
33
import klaw from "klaw";
44
import path from "node:path";
55

6+
/**
7+
* @param value -
8+
* @param version -
9+
* @returns -
10+
*/
11+
function resolveWorkspaceVersion(value: string, version: string): string {
12+
if (!value.startsWith("workspace:")) {
13+
return value;
14+
}
15+
16+
const spec = value.slice("workspace:".length);
17+
18+
if (!spec || spec === "*") {
19+
return version;
20+
}
21+
22+
if (spec === "^" || spec === "~") {
23+
return `${spec}${version}`;
24+
}
25+
26+
return spec;
27+
}
28+
29+
/**
30+
* @param deps -
31+
* @param version -
32+
* @returns -
33+
*/
34+
function resolveDeps(deps: Record<string, string>, version: string): Record<string, string> {
35+
return Object.fromEntries(
36+
Object.entries(deps).map(([name, value]) => [
37+
name,
38+
resolveWorkspaceVersion(value, version),
39+
]),
40+
);
41+
}
42+
643
/**
744
* @param basePath -
845
* @param silent -
@@ -31,11 +68,11 @@ export async function buildDistFiles(basePath: string, silent: boolean): Promise
3168
libObj["version"] = pkgInfo.version;
3269

3370
if (pkgInfo.dependencies) {
34-
libObj["dependencies"] = JSON.parse(JSON.stringify(pkgInfo.dependencies).replaceAll("workspace:", ""));
71+
libObj["dependencies"] = resolveDeps(pkgInfo.dependencies, pkgInfo.version);
3572
}
3673

3774
if (pkgInfo.peerDependencies) {
38-
libObj["peerDependencies"] = JSON.parse(JSON.stringify(pkgInfo.peerDependencies).replaceAll("workspace:", ""));
75+
libObj["peerDependencies"] = resolveDeps(pkgInfo.peerDependencies, pkgInfo.version);
3976
}
4077

4178
const jsonIndent = 2,

0 commit comments

Comments
 (0)