Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

Try to use `golden-fleece` to handle tsconfig containing comments

Mateusz Burzyński75cb3252e5ce
diff --git a/apps/designer/tsconfig.json b/apps/designer/tsconfig.json
index c571d7ff96..e609eb8862 100644
--- a/apps/designer/tsconfig.json
+++ b/apps/designer/tsconfig.json
@@ -1,4 +1,5 @@
{
+ // Extends can't use node's resolution rn https://github.com/dividab/tsconfig-paths/issues/209#issuecomment-1177261091
"extends": "../../node_modules/@webstudio-is/tsconfig/remix.json",
"include": ["remix.env.d.ts", "**/*.ts", "**/*.tsx"],
"compilerOptions": {
diff --git a/bin/update-ts-project-references.ts b/bin/update-ts-project-references.ts
index c62d530a19..cfdaf0af5b 100644
--- a/bin/update-ts-project-references.ts
+++ b/bin/update-ts-project-references.ts
@@ -4,6 +4,7 @@ import fsP from "fs/promises";
import path from "path";
import { getDependentsGraph } from "@changesets/get-dependents-graph";
import { getPackages } from "@manypkg/get-packages";
+import * as fleece from "golden-fleece";
type GetPackagesResult = Awaited<ReturnType<typeof getPackages>>;
type Package = GetPackagesResult["packages"][number];
@@ -58,7 +59,7 @@ const updateTsConfig = async (
) => {
const tsConfigPath = path.join(dependentDir, "tsconfig.json");
const tsConfigContent = await fsP.readFile(tsConfigPath, "utf8");
- const tsConfig: TsConfig = JSON.parse(tsConfigContent);
+ const tsConfig: TsConfig = fleece.evaluate(tsConfigContent);
const dependencyPaths = [...dependencies.values()]
.filter((dependency) =>
@@ -78,7 +79,7 @@ const updateTsConfig = async (
await updateFile(
tsConfigPath,
- JSON.stringify({
+ fleece.patch(tsConfigContent, {
...tsConfig,
references: dependencyPaths.map((path) => ({ path })),
})
diff --git a/package.json b/package.json
index 4707a6f701..9d14ff4ead 100644
--- a/package.json
+++ b/package.json
@@ -34,7 +34,9 @@
"npm": ">=7.0.0",
"node": "16"
},
- "dependencies": {},
+ "dependencies": {
+ "golden-fleece": "^1.0.9"
+ },
"packageManager": "[email protected]",
"lint-staged": {
"*.{ts,tsx,js,json,css,md}": "prettier --write"
diff --git a/packages/asset-uploader/tsconfig.json b/packages/asset-uploader/tsconfig.json
index c8b1e47550..c0d809d686 100644
--- a/packages/asset-uploader/tsconfig.json
+++ b/packages/asset-uploader/tsconfig.json
@@ -1,4 +1,5 @@
{
+ // Extends can't use node's resolution rn https://github.com/dividab/tsconfig-paths/issues/209#issuecomment-1177261091
"extends": "../../node_modules/@webstudio-is/tsconfig/base.json",
"include": ["./src/**/*.ts"],
"compilerOptions": {
diff --git a/packages/css-vars/tsconfig.json b/packages/css-vars/tsconfig.json
index e6c2bd5350..d55df5e9ec 100644
--- a/packages/css-vars/tsconfig.json
+++ b/packages/css-vars/tsconfig.json
@@ -1,4 +1,5 @@
{
+ // Extends can't use node's resolution rn https://github.com/dividab/tsconfig-paths/issues/209#issuecomment-1177261091
"extends": "../../node_modules/@webstudio-is/tsconfig/base.json",
"include": ["./src/**/*.ts"],
"compilerOptions": {
diff --git a/packages/design-system/tsconfig.json b/packages/design-system/tsconfig.json
index d66d9acb14..b39de39198 100644
--- a/packages/design-system/tsconfig.json
+++ b/packages/design-system/tsconfig.json
@@ -1,4 +1,5 @@
{
+ // Extends can't use node's resolution rn https://github.com/dividab/tsconfig-paths/issues/209#issuecomment-1177261091
"extends": "../../node_modules/@webstudio-is/tsconfig/base.json",
"include": ["./src/**/*.ts", "./src/**/*.tsx"],
"compilerOptions": {
diff --git a/packages/fonts/tsconfig.json b/packages/fonts/tsconfig.json
index 8dbc7e0b4b..21d7207317 100644
--- a/packages/fonts/tsconfig.json
+++ b/packages/fonts/tsconfig.json
@@ -1,4 +1,5 @@
{
+ // Extends can't use node's resolution rn https://github.com/dividab/tsconfig-paths/issues/209#issuecomment-1177261091
"extends": "../../node_modules/@webstudio-is/tsconfig/base.json",
"include": ["./src/**/*.ts"],
"compilerOptions": {
diff --git a/packages/http-client/tsconfig.json b/packages/http-client/tsconfig.json
index d301e0daf1..6a2c43ec4b 100644
--- a/packages/http-client/tsconfig.json
+++ b/packages/http-client/tsconfig.json
@@ -1,4 +1,5 @@
{
+ // Extends can't use node's resolution rn https://github.com/dividab/tsconfig-paths/issues/209#issuecomment-1177261091
"extends": "../../node_modules/@webstudio-is/tsconfig/base.json",
"include": ["./src/**/*.ts", "./src/**/*.tsx"],
"compilerOptions": {
diff --git a/packages/icons/tsconfig.json b/packages/icons/tsconfig.json
index 538cc63991..8d4b89d38a 100644
--- a/packages/icons/tsconfig.json
+++ b/packages/icons/tsconfig.json
@@ -1,4 +1,5 @@
{
+ // Extends can't use node's resolution rn https://github.com/dividab/tsconfig-paths/issues/209#issuecomment-1177261091
"extends": "../../node_modules/@webstudio-is/tsconfig/base.json",
"include": ["./src/**/*.ts", "./src/**/*.tsx"],
"compilerOptions": {
diff --git a/packages/prisma-client/tsconfig.json b/packages/prisma-client/tsconfig.json
index 2f306d05be..0918fc98dc 100644
--- a/packages/prisma-client/tsconfig.json
+++ b/packages/prisma-client/tsconfig.json
@@ -1,4 +1,5 @@
{
+ // Extends can't use node's resolution rn https://github.com/dividab/tsconfig-paths/issues/209#issuecomment-1177261091
"extends": "../../node_modules/@webstudio-is/tsconfig/base.json",
"include": ["./src/**/*.ts"],
"compilerOptions": {
diff --git a/packages/project/tsconfig.json b/packages/project/tsconfig.json
index ed784c723d..e6581e082b 100644
--- a/packages/project/tsconfig.json
+++ b/packages/project/tsconfig.json
@@ -1,4 +1,5 @@
{
+ // Extends can't use node's resolution rn https://github.com/dividab/tsconfig-paths/issues/209#issuecomment-1177261091
"extends": "../../node_modules/@webstudio-is/tsconfig/base.json",
"include": ["./src/**/*.ts"],
"compilerOptions": {
diff --git a/packages/react-sdk/tsconfig.json b/packages/react-sdk/tsconfig.json
index fbd86822e8..b0a647e672 100644
--- a/packages/react-sdk/tsconfig.json
+++ b/packages/react-sdk/tsconfig.json
@@ -1,4 +1,5 @@
{
+ // Extends can't use node's resolution rn https://github.com/dividab/tsconfig-paths/issues/209#issuecomment-1177261091
"extends": "../../node_modules/@webstudio-is/tsconfig/base.json",
"include": ["./src/**/*.ts", "./src/**/*.tsx", "./src/**/*.json"],
"compilerOptions": {
diff --git a/yarn.lock b/yarn.lock
index 77a1941730..afd190b868 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -10721,6 +10721,11 @@ globby@^9.2.0:
pify "^4.0.1"
slash "^2.0.0"
+golden-fleece@^1.0.9:
+ version "1.0.9"
+ resolved "https://registry.yarnpkg.com/golden-fleece/-/golden-fleece-1.0.9.tgz#0c4cbba8b493c8ab4cd4023404317a97785306f3"
+ integrity sha512-YSwLaGMOgSBx9roJlNLL12c+FRiw7VECphinc6mGucphc/ZxTHgdEz6gmJqH6NOzYEd/yr64hwjom5pZ+tJVpg==
+
goober@^2.1.10:
version "2.1.10"
resolved "https://registry.yarnpkg.com/goober/-/goober-2.1.10.tgz#058def43ba1e3b06f973dbb372a4978aa42f1049"