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.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
refactor: merge tsconfig from CLI templates (#3774)
Bogdan Chadkin2518719ba92f
diff --git a/fixtures/webstudio-cloudflare-template/package.json b/fixtures/webstudio-cloudflare-template/package.jsonindex 54da43c620..154ee324ea 100644--- a/fixtures/webstudio-cloudflare-template/package.json+++ b/fixtures/webstudio-cloudflare-template/package.json@@ -4,7 +4,7 @@"cli": "NODE_OPTIONS='--conditions=webstudio --import=tsx' webstudio","fixtures:link": "pnpm cli link --link \"https://main.development.webstudio.is/builder/d845c167-ea07-4875-b08d-83e97c09dcce?authToken=e9d1343f-9298-4fd3-a66e-f89a5af2dd93&\"","fixtures:sync": "pnpm cli sync && pnpm prettier --write ./.webstudio/",- "fixtures:build": "pnpm cli build --template internal --template cloudflare --template saas-helpers --preview && pnpm prettier --write ./app/ ./package.json",+ "fixtures:build": "pnpm cli build --template internal --template cloudflare --template saas-helpers --preview && pnpm prettier --write ./app/ ./package.json ./tsconfig.json","build": "remix vite:build","dev": "remix vite:dev","typecheck": "tsc",diff --git a/fixtures/webstudio-cloudflare-template/tsconfig.json b/fixtures/webstudio-cloudflare-template/tsconfig.jsonindex a87a7c9a55..24c0849f69 100644--- a/fixtures/webstudio-cloudflare-template/tsconfig.json+++ b/fixtures/webstudio-cloudflare-template/tsconfig.json@@ -8,7 +8,7 @@"**/.client/**/*.tsx"],"compilerOptions": {- "lib": ["DOM", "DOM.Iterable", "ES2023"],+ "lib": ["DOM", "DOM.Iterable", "ESNext"],"types": ["@remix-run/cloudflare","vite/client",@@ -19,17 +19,13 @@"esModuleInterop": true,"jsx": "react-jsx","module": "ESNext",- "moduleResolution": "Bundler",- "resolveJsonModule": true,+ "moduleResolution": "bundler","target": "ES2022","strict": true,"allowJs": true,- "skipLibCheck": true,"forceConsistentCasingInFileNames": true,- "baseUrl": ".",- "customConditions": ["webstudio"],-- // Vite takes care of building everything, not tsc.- "noEmit": true+ "noEmit": true,+ "skipLibCheck": true,+ "customConditions": ["webstudio"]}}diff --git a/fixtures/webstudio-custom-template/package.json b/fixtures/webstudio-custom-template/package.jsonindex 0381322e35..a1eb7a5c8e 100644--- a/fixtures/webstudio-custom-template/package.json+++ b/fixtures/webstudio-custom-template/package.json@@ -8,7 +8,7 @@"cli": "NODE_OPTIONS='--conditions=webstudio --import=tsx' webstudio","fixtures:link": "pnpm cli link --link \"https://main.development.webstudio.is/builder/0d856812-61d8-4014-a20a-82e01c0eb8ee?authToken=d225fafb-4f20-4340-9359-c21df7c49a3f\"","fixtures:sync": "pnpm cli sync && pnpm prettier --write ./.webstudio/",- "fixtures:build": "pnpm cli build --template internal --template ./custom-template --template ./custom-template-stage --preview && pnpm prettier --write ./app/ ./package.json"+ "fixtures:build": "pnpm cli build --template internal --template ./custom-template --template ./custom-template-stage --preview && pnpm prettier --write ./app/ ./package.json ./tsconfig.json"},"private": true,"sideEffects": false,diff --git a/fixtures/webstudio-custom-template/tsconfig.json b/fixtures/webstudio-custom-template/tsconfig.jsonindex cf25de4181..99e0e652cc 100644--- a/fixtures/webstudio-custom-template/tsconfig.json+++ b/fixtures/webstudio-custom-template/tsconfig.json@@ -1,7 +1,7 @@{"include": ["**/*.ts", "**/*.tsx", "**/*.mjs"],"compilerOptions": {- "lib": ["DOM", "DOM.Iterable", "ES2023"],+ "lib": ["DOM", "DOM.Iterable", "ESNext"],"types": ["@remix-run/node","vite/client",@@ -12,18 +12,12 @@"jsx": "react-jsx","module": "ESNext","moduleResolution": "bundler",- "resolveJsonModule": true,"target": "ES2022","strict": true,"allowJs": true,- "checkJs": true,"forceConsistentCasingInFileNames": true,- "allowImportingTsExtensions": true,- "baseUrl": ".",- "customConditions": ["webstudio"],-- // Remix takes care of building everything in `remix build`."noEmit": true,- "skipLibCheck": true+ "skipLibCheck": true,+ "customConditions": ["webstudio"]}}diff --git a/fixtures/webstudio-remix-netlify-edge-functions/package.json b/fixtures/webstudio-remix-netlify-edge-functions/package.jsonindex 10c4ec4993..d85badfc9e 100644--- a/fixtures/webstudio-remix-netlify-edge-functions/package.json+++ b/fixtures/webstudio-remix-netlify-edge-functions/package.json@@ -8,7 +8,7 @@"cli": "NODE_OPTIONS='--conditions=webstudio --import=tsx' webstudio","fixtures:link": "pnpm cli link --link \"https://main.development.webstudio.is/builder/d845c167-ea07-4875-b08d-83e97c09dcce?authToken=e9d1343f-9298-4fd3-a66e-f89a5af2dd93&\"","fixtures:sync": "pnpm cli sync && pnpm prettier --write ./.webstudio/",- "fixtures:build": "pnpm cli build --template internal --template netlify-edge-functions --preview && pnpm prettier --write ./app/ ./package.json"+ "fixtures:build": "pnpm cli build --template internal --template netlify-edge-functions --preview && pnpm prettier --write ./app/ ./package.json ./tsconfig.json"},"dependencies": {"@netlify/edge-functions": "^2.10.0",diff --git a/fixtures/webstudio-remix-netlify-edge-functions/tsconfig.json b/fixtures/webstudio-remix-netlify-edge-functions/tsconfig.jsonindex cf25de4181..99e0e652cc 100644--- a/fixtures/webstudio-remix-netlify-edge-functions/tsconfig.json+++ b/fixtures/webstudio-remix-netlify-edge-functions/tsconfig.json@@ -1,7 +1,7 @@{"include": ["**/*.ts", "**/*.tsx", "**/*.mjs"],"compilerOptions": {- "lib": ["DOM", "DOM.Iterable", "ES2023"],+ "lib": ["DOM", "DOM.Iterable", "ESNext"],"types": ["@remix-run/node","vite/client",@@ -12,18 +12,12 @@"jsx": "react-jsx","module": "ESNext","moduleResolution": "bundler",- "resolveJsonModule": true,"target": "ES2022","strict": true,"allowJs": true,- "checkJs": true,"forceConsistentCasingInFileNames": true,- "allowImportingTsExtensions": true,- "baseUrl": ".",- "customConditions": ["webstudio"],-- // Remix takes care of building everything in `remix build`."noEmit": true,- "skipLibCheck": true+ "skipLibCheck": true,+ "customConditions": ["webstudio"]}}diff --git a/fixtures/webstudio-remix-netlify-functions/package.json b/fixtures/webstudio-remix-netlify-functions/package.jsonindex b9f9af8ff7..8e8f002dfa 100644--- a/fixtures/webstudio-remix-netlify-functions/package.json+++ b/fixtures/webstudio-remix-netlify-functions/package.json@@ -7,7 +7,7 @@"cli": "NODE_OPTIONS='--conditions=webstudio --import=tsx' webstudio","fixtures:link": "pnpm cli link --link \"https://main.development.webstudio.is/builder/d845c167-ea07-4875-b08d-83e97c09dcce?authToken=e9d1343f-9298-4fd3-a66e-f89a5af2dd93\"","fixtures:sync": "pnpm cli sync && pnpm prettier --write ./.webstudio/",- "fixtures:build": "pnpm cli build --template internal --template netlify-functions --preview && pnpm prettier --write ./app/ ./package.json"+ "fixtures:build": "pnpm cli build --template internal --template netlify-functions --preview && pnpm prettier --write ./app/ ./package.json ./tsconfig.json"},"dependencies": {"@netlify/functions": "^2.8.1",diff --git a/fixtures/webstudio-remix-netlify-functions/tsconfig.json b/fixtures/webstudio-remix-netlify-functions/tsconfig.jsonindex cf25de4181..99e0e652cc 100644--- a/fixtures/webstudio-remix-netlify-functions/tsconfig.json+++ b/fixtures/webstudio-remix-netlify-functions/tsconfig.json@@ -1,7 +1,7 @@{"include": ["**/*.ts", "**/*.tsx", "**/*.mjs"],"compilerOptions": {- "lib": ["DOM", "DOM.Iterable", "ES2023"],+ "lib": ["DOM", "DOM.Iterable", "ESNext"],"types": ["@remix-run/node","vite/client",@@ -12,18 +12,12 @@"jsx": "react-jsx","module": "ESNext","moduleResolution": "bundler",- "resolveJsonModule": true,"target": "ES2022","strict": true,"allowJs": true,- "checkJs": true,"forceConsistentCasingInFileNames": true,- "allowImportingTsExtensions": true,- "baseUrl": ".",- "customConditions": ["webstudio"],-- // Remix takes care of building everything in `remix build`."noEmit": true,- "skipLibCheck": true+ "skipLibCheck": true,+ "customConditions": ["webstudio"]}}diff --git a/fixtures/webstudio-remix-vercel/package.json b/fixtures/webstudio-remix-vercel/package.jsonindex a660249a48..65d77f7269 100644--- a/fixtures/webstudio-remix-vercel/package.json+++ b/fixtures/webstudio-remix-vercel/package.json@@ -7,7 +7,7 @@"cli": "NODE_OPTIONS='--conditions=webstudio --import=tsx' webstudio","fixtures:link": "pnpm cli link --link \"https://main.development.webstudio.is/builder/cddc1d44-af37-4cb6-a430-d300cf6f932d?authToken=1cdc6026-dd5b-4624-b89b-9bd45e9bcc3d&mode=preview\"","fixtures:sync": "pnpm cli sync && pnpm prettier --write ./.webstudio/",- "fixtures:build": "pnpm cli build --template internal --template vercel --preview && pnpm prettier --write ./app/ ./package.json"+ "fixtures:build": "pnpm cli build --template internal --template vercel --preview && pnpm prettier --write ./app/ ./package.json ./tsconfig.json"},"private": true,"sideEffects": false,diff --git a/fixtures/webstudio-remix-vercel/tsconfig.json b/fixtures/webstudio-remix-vercel/tsconfig.jsonindex cf25de4181..99e0e652cc 100644--- a/fixtures/webstudio-remix-vercel/tsconfig.json+++ b/fixtures/webstudio-remix-vercel/tsconfig.json@@ -1,7 +1,7 @@{"include": ["**/*.ts", "**/*.tsx", "**/*.mjs"],"compilerOptions": {- "lib": ["DOM", "DOM.Iterable", "ES2023"],+ "lib": ["DOM", "DOM.Iterable", "ESNext"],"types": ["@remix-run/node","vite/client",@@ -12,18 +12,12 @@"jsx": "react-jsx","module": "ESNext","moduleResolution": "bundler",- "resolveJsonModule": true,"target": "ES2022","strict": true,"allowJs": true,- "checkJs": true,"forceConsistentCasingInFileNames": true,- "allowImportingTsExtensions": true,- "baseUrl": ".",- "customConditions": ["webstudio"],-- // Remix takes care of building everything in `remix build`."noEmit": true,- "skipLibCheck": true+ "skipLibCheck": true,+ "customConditions": ["webstudio"]}}diff --git a/packages/cli/src/prebuild.ts b/packages/cli/src/prebuild.tsindex 826eb401f2..4483c3c097 100644--- a/packages/cli/src/prebuild.ts+++ b/packages/cli/src/prebuild.ts@@ -1,5 +1,5 @@import { basename, dirname, join, normalize, relative } from "node:path";-import { createWriteStream } from "node:fs";+import { createWriteStream, existsSync } from "node:fs";import {rm,access,@@ -54,7 +54,6 @@ import {createFileIfNotExists,createFolderIfNotExists,loadJSONFile,- isFileExists,} from "./fs-utils";import type * as sharedConstants from "../templates/defaults/app/constants.mjs";import { htmlToJsx } from "./html-to-jsx";@@ -137,7 +136,9 @@ const mergeJsonInto = async (sourcePath: string, destinationPath: string) => {});const content = JSON.stringify(- merge(JSON.parse(destinationJson), JSON.parse(sourceJson)),+ merge(JSON.parse(destinationJson), JSON.parse(sourceJson), {+ arrayMerge: (_target, source) => source,+ }),null," ");@@ -184,16 +185,23 @@ const copyTemplates = async (template: string = "defaults") => {await cp(templatePath, cwd(), {recursive: true,filter: (source) => {- return basename(source) !== "package.json";+ const name = basename(source);+ return name !== "package.json" && name !== "tsconfig.json";},});- if ((await isFileExists(join(templatePath, "package.json"))) === true) {+ if (existsSync(join(templatePath, "package.json"))) {await mergeJsonInto(join(templatePath, "package.json"),join(cwd(), "package.json"));}+ if (existsSync(join(templatePath, "tsconfig.json"))) {+ await mergeJsonInto(+ join(templatePath, "tsconfig.json"),+ join(cwd(), "tsconfig.json")+ );+ }};const importFrom = (importee: string, importer: string) => {diff --git a/packages/cli/templates/cloudflare/tsconfig.json b/packages/cli/templates/cloudflare/tsconfig.jsonindex c9f03092bb..6ee0d3c263 100644--- a/packages/cli/templates/cloudflare/tsconfig.json+++ b/packages/cli/templates/cloudflare/tsconfig.json@@ -8,27 +8,11 @@"**/.client/**/*.tsx"],"compilerOptions": {- "lib": ["DOM", "DOM.Iterable", "ES2023"],"types": ["@remix-run/cloudflare","vite/client","@cloudflare/workers-types/2023-07-01","@webstudio-is/react-sdk/placeholder"- ],- "isolatedModules": true,- "esModuleInterop": true,- "jsx": "react-jsx",- "module": "ESNext",- "moduleResolution": "Bundler",- "resolveJsonModule": true,- "target": "ES2022",- "strict": true,- "allowJs": true,- "skipLibCheck": true,- "forceConsistentCasingInFileNames": true,- "baseUrl": ".",-- // Vite takes care of building everything, not tsc.- "noEmit": true+ ]}}diff --git a/packages/cli/templates/defaults/tsconfig.json b/packages/cli/templates/defaults/tsconfig.jsonindex 484c8fe946..f16e949651 100644--- a/packages/cli/templates/defaults/tsconfig.json+++ b/packages/cli/templates/defaults/tsconfig.json@@ -12,15 +12,10 @@"jsx": "react-jsx","module": "ESNext","moduleResolution": "bundler",- "resolveJsonModule": true,"target": "ES2022","strict": true,"allowJs": true,- "checkJs": true,"forceConsistentCasingInFileNames": true,- "allowImportingTsExtensions": true,- "baseUrl": ".",- // Remix takes care of building everything in `remix build`."noEmit": true,"skipLibCheck": true}diff --git a/packages/cli/templates/internal/tsconfig.json b/packages/cli/templates/internal/tsconfig.jsonindex cf25de4181..75cac78946 100644--- a/packages/cli/templates/internal/tsconfig.json+++ b/packages/cli/templates/internal/tsconfig.json@@ -1,29 +1,5 @@{- "include": ["**/*.ts", "**/*.tsx", "**/*.mjs"],"compilerOptions": {- "lib": ["DOM", "DOM.Iterable", "ES2023"],- "types": [- "@remix-run/node",- "vite/client",- "@webstudio-is/react-sdk/placeholder"- ],- "isolatedModules": true,- "esModuleInterop": true,- "jsx": "react-jsx",- "module": "ESNext",- "moduleResolution": "bundler",- "resolveJsonModule": true,- "target": "ES2022",- "strict": true,- "allowJs": true,- "checkJs": true,- "forceConsistentCasingInFileNames": true,- "allowImportingTsExtensions": true,- "baseUrl": ".",- "customConditions": ["webstudio"],-- // Remix takes care of building everything in `remix build`.- "noEmit": true,- "skipLibCheck": true+ "customConditions": ["webstudio"]}}diff --git a/packages/cli/templates/saas-helpers/tsconfig.json b/packages/cli/templates/saas-helpers/tsconfig.jsonindex a87a7c9a55..6ee0d3c263 100644--- a/packages/cli/templates/saas-helpers/tsconfig.json+++ b/packages/cli/templates/saas-helpers/tsconfig.json@@ -8,28 +8,11 @@"**/.client/**/*.tsx"],"compilerOptions": {- "lib": ["DOM", "DOM.Iterable", "ES2023"],"types": ["@remix-run/cloudflare","vite/client","@cloudflare/workers-types/2023-07-01","@webstudio-is/react-sdk/placeholder"- ],- "isolatedModules": true,- "esModuleInterop": true,- "jsx": "react-jsx",- "module": "ESNext",- "moduleResolution": "Bundler",- "resolveJsonModule": true,- "target": "ES2022",- "strict": true,- "allowJs": true,- "skipLibCheck": true,- "forceConsistentCasingInFileNames": true,- "baseUrl": ".",- "customConditions": ["webstudio"],-- // Vite takes care of building everything, not tsc.- "noEmit": true+ ]}}