From 1172a20a3b2126ffecd938788af924750d7d30c5 Mon Sep 17 00:00:00 2001 From: Martin Lysk Date: Tue, 16 Apr 2024 11:24:42 +0200 Subject: [PATCH 01/11] moves tsc --noEmit from test to build phase and adds it where it was missing --- inlang/source-code/cli/package.json | 4 +-- inlang/source-code/editor/package.json | 4 +-- .../github-lint-action/package.json | 4 +-- inlang/source-code/ide-extension/package.json | 4 +-- .../example/package.json | 2 +- .../example/package.json | 2 +- .../example/package.json | 2 +- .../package.json | 2 +- .../example/package.json | 2 +- .../example/package.json | 30 +++++++++---------- .../paraglide/paraglide-js/package.json | 4 +-- inlang/source-code/website/package.json | 4 +-- lix/packages/exp/package.json | 2 +- lix/packages/server/package.json | 2 +- 14 files changed, 34 insertions(+), 34 deletions(-) diff --git a/inlang/source-code/cli/package.json b/inlang/source-code/cli/package.json index bf3b72908c..b2a5b7fc31 100644 --- a/inlang/source-code/cli/package.json +++ b/inlang/source-code/cli/package.json @@ -33,8 +33,8 @@ ], "scripts": { "dev": "node ./build.js", - "build": "cross-env NODE_ENV=production node ./build.js", - "test": "tsc --noEmit && vitest run --passWithNoTests --coverage --test-timeout=10000", + "build": "cross-env NODE_ENV=production node ./build.js && tsc --noEmit", + "test": "vitest run --passWithNoTests --coverage --test-timeout=10000", "lint": "eslint ./src --fix", "format": "prettier ./src --write", "clean": "rm -rf ./dist ./node_modules" diff --git a/inlang/source-code/editor/package.json b/inlang/source-code/editor/package.json index 49077aece2..153217cf8c 100644 --- a/inlang/source-code/editor/package.json +++ b/inlang/source-code/editor/package.json @@ -4,10 +4,10 @@ "private": true, "scripts": { "dev": "vite", - "build": "paraglide-js compile --project ../../../project.inlang && vite build -- --max_old_space_size=1200000", + "build": "paraglide-js compile --project ../../../project.inlang && tsc --noEmit && vite build -- --max_old_space_size=1200000", "production": "NODE_ENV=production tsx ./src/server/main.ts", "---- TEST ----------------------------------------------------------": "", - "test": "paraglide-js compile --project ../../../project.inlang && tsc --noEmit", + "test": "paraglide-js compile --project ../../../project.inlang", "lint": "eslint ./src --fix", "format": "prettier ./src --write", "clean": "rm -rf ./dist ./node_modules" diff --git a/inlang/source-code/github-lint-action/package.json b/inlang/source-code/github-lint-action/package.json index 2f3daa8cde..993d006ce0 100644 --- a/inlang/source-code/github-lint-action/package.json +++ b/inlang/source-code/github-lint-action/package.json @@ -25,8 +25,8 @@ }, "scripts": { "dev": "node ./build.js", - "build": "pnpm run format && esbuild src/index.ts --bundle --platform=node --target=node20 --outfile=dist/index.cjs", - "test": "tsc --noEmit && vitest run --passWithNoTests --coverage --test-timeout=10000", + "build": "pnpm run format && tsc --noEmit && esbuild src/index.ts --bundle --platform=node --target=node20 --outfile=dist/index.cjs", + "test": "vitest run --passWithNoTests --coverage --test-timeout=10000", "lint": "eslint ./src --fix", "format": "prettier --write **/*.ts", "clean": "rm -rf ./dist ./node_modules" diff --git a/inlang/source-code/ide-extension/package.json b/inlang/source-code/ide-extension/package.json index cfb9a59124..3429120621 100644 --- a/inlang/source-code/ide-extension/package.json +++ b/inlang/source-code/ide-extension/package.json @@ -143,14 +143,14 @@ }, "scripts": { "check": "tsc --noEmit", - "build": "node ./build.js", + "build": "tsc --noEmit && node ./build.js", "dev": "DEV=true node ./build.js", "package": "pnpm vsce package --no-dependencies", "publish": "pnpm vsce publish --no-dependencies", "vscode:prepublish": "npm run build", "---- TEST ----------------------------------------------------------": "", "pretest": "node ./build.js", - "test": "tsc --noEmit && vitest run --passWithNoTests --coverage", + "test": "vitest run --passWithNoTests --coverage", "test:e2e": "npm run pretest && wdio run ./test/wdio.conf.ts", "---- LINT ----------------------------------------------------------": "", "lint": "eslint ./src --fix", diff --git a/inlang/source-code/paraglide/paraglide-js-adapter-astro/example/package.json b/inlang/source-code/paraglide/paraglide-js-adapter-astro/example/package.json index 51461cf155..62a0ed5977 100644 --- a/inlang/source-code/paraglide/paraglide-js-adapter-astro/example/package.json +++ b/inlang/source-code/paraglide/paraglide-js-adapter-astro/example/package.json @@ -6,7 +6,7 @@ "scripts": { "_dev": "astro dev", "start": "astro dev", - "build": "paraglide-js compile --project ./project.inlang && astro check && astro build", + "build": "paraglide-js compile --project ./project.inlang && tsc --noEmit && astro check && astro build", "preview": "astro preview", "astro": "astro" }, diff --git a/inlang/source-code/paraglide/paraglide-js-adapter-rollup/example/package.json b/inlang/source-code/paraglide/paraglide-js-adapter-rollup/example/package.json index c1c8710aa2..c5c8266b0e 100644 --- a/inlang/source-code/paraglide/paraglide-js-adapter-rollup/example/package.json +++ b/inlang/source-code/paraglide/paraglide-js-adapter-rollup/example/package.json @@ -4,7 +4,7 @@ "version": "0.0.0", "type": "module", "scripts": { - "build": "rollup src/main.js --config rollup.config.js", + "build": "tsc --noEmit && rollup src/main.js --config rollup.config.js", "clean": "rm -rf ./dist ./node_modules ./src/paraglide" }, "devDependencies": { diff --git a/inlang/source-code/paraglide/paraglide-js-adapter-sveltekit/example/package.json b/inlang/source-code/paraglide/paraglide-js-adapter-sveltekit/example/package.json index 58eabf61c9..506ab62724 100644 --- a/inlang/source-code/paraglide/paraglide-js-adapter-sveltekit/example/package.json +++ b/inlang/source-code/paraglide/paraglide-js-adapter-sveltekit/example/package.json @@ -5,7 +5,7 @@ "scripts": { "_dev": "vite dev", "start": "vite dev", - "build": "vite build", + "build": "paraglide-js compile --project ./project.inlang && tsc --noEmit && vite build", "test": "vite build", "preview": "vite preview", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", diff --git a/inlang/source-code/paraglide/paraglide-js-adapter-sveltekit/package.json b/inlang/source-code/paraglide/paraglide-js-adapter-sveltekit/package.json index bac0e8c49c..0f598c3120 100644 --- a/inlang/source-code/paraglide/paraglide-js-adapter-sveltekit/package.json +++ b/inlang/source-code/paraglide/paraglide-js-adapter-sveltekit/package.json @@ -15,7 +15,7 @@ "test:with-base": "BASE_PATH=/base vitest run --test-timeout 30000 --dir src", "test:without-base": "BASE_PATH=\"\" vitest run --test-timeout 30000 --dir src", "test": "npm run test:with-base && npm run test:without-base", - "build": "svelte-package -i src -o dist", + "build": "tsc --noEmit && svelte-package -i src -o dist", "dev": "svelte-package -w -i src -o dist", "lint": "eslint ./src --fix", "format": "prettier ./src --write", diff --git a/inlang/source-code/paraglide/paraglide-js-adapter-vite/example/package.json b/inlang/source-code/paraglide/paraglide-js-adapter-vite/example/package.json index af3364f68a..64195f900c 100644 --- a/inlang/source-code/paraglide/paraglide-js-adapter-vite/example/package.json +++ b/inlang/source-code/paraglide/paraglide-js-adapter-vite/example/package.json @@ -5,7 +5,7 @@ "type": "module", "scripts": { "_dev": "vite dev", - "build": "vite build", + "build": "tsc --noEmit && vite build", "clean": "rm -rf ./dist ./node_modules ./src/paraglide" }, "devDependencies": { diff --git a/inlang/source-code/paraglide/paraglide-js-adapter-webpack/example/package.json b/inlang/source-code/paraglide/paraglide-js-adapter-webpack/example/package.json index 1198b9bf9c..6da3e0d24e 100644 --- a/inlang/source-code/paraglide/paraglide-js-adapter-webpack/example/package.json +++ b/inlang/source-code/paraglide/paraglide-js-adapter-webpack/example/package.json @@ -1,17 +1,17 @@ { - "name": "@inlang/paraglide-js-adapter-webpack-example", - "private": true, - "version": "0.0.0", - "type": "module", - "scripts": { - "build": "webpack --config webpack.config.js", - "clean": "rm -rf ./dist ./node_modules ./src/paraglide" - }, - "devDependencies": { - "@inlang/paraglide-js": "workspace:*", - "@inlang/paraglide-js-adapter-webpack": "workspace:*", - "typescript": "^4.9.3", - "webpack": "^5.89.0", - "webpack-cli": "^5.1.4" - } + "name": "@inlang/paraglide-js-adapter-webpack-example", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "build": "tsc --noEmit && webpack --config webpack.config.js", + "clean": "rm -rf ./dist ./node_modules ./src/paraglide" + }, + "devDependencies": { + "@inlang/paraglide-js": "workspace:*", + "@inlang/paraglide-js-adapter-webpack": "workspace:*", + "typescript": "^4.9.3", + "webpack": "^5.89.0", + "webpack-cli": "^5.1.4" + } } \ No newline at end of file diff --git a/inlang/source-code/paraglide/paraglide-js/package.json b/inlang/source-code/paraglide/paraglide-js/package.json index d245e81f0a..e6a3265438 100644 --- a/inlang/source-code/paraglide/paraglide-js/package.json +++ b/inlang/source-code/paraglide/paraglide-js/package.json @@ -42,8 +42,8 @@ ], "scripts": { "dev": "vite build --mode development --watch", - "build": "vite build --mode production", - "test": "tsc --noEmit --emitDeclarationOnly false && vitest run --coverage ./src/**/*", + "build": "tsc --noEmit --emitDeclarationOnly false && vite build --mode production", + "test": "vitest run --coverage ./src/**/*", "lint": "eslint ./src --fix", "format": "prettier ./src --write", "clean": "rm -rf ./dist ./node_modules" diff --git a/inlang/source-code/website/package.json b/inlang/source-code/website/package.json index 16cd413cd9..9de920d725 100644 --- a/inlang/source-code/website/package.json +++ b/inlang/source-code/website/package.json @@ -4,10 +4,10 @@ "private": true, "scripts": { "dev": "vite", - "build": "node ./scripts/generateSitemap.js && npx @inlang/cli machine translate -f --project ../../../project.inlang --targetLanguageTags fr,it,pt-BR,sk,zh && vite build", + "build": "node ./scripts/generateSitemap.js && npx @inlang/cli machine translate -f --project ../../../project.inlang --targetLanguageTags fr,it,pt-BR,sk,zh && tsc --noEmit && vite build", "production": "NODE_ENV=production tsx ./src/server/main.ts ", "---- TEST ----------------------------------------------------------": "", - "test": "paraglide-js compile --project ../../../project.inlang && npx @inlang/cli lint --project ../../../project.inlang --languageTags de,en && tsc --noEmit ", + "test": "paraglide-js compile --project ../../../project.inlang && npx @inlang/cli lint --project ../../../project.inlang --languageTags de,en ", "lint": "eslint ./src --fix", "format": "prettier ./src --write", "clean": "rm -rf ./dist ./node_modules" diff --git a/lix/packages/exp/package.json b/lix/packages/exp/package.json index a8cbfa8f62..d0d2ab309f 100644 --- a/lix/packages/exp/package.json +++ b/lix/packages/exp/package.json @@ -4,7 +4,7 @@ "type": "module", "scripts": { "dev": "vite", - "build": "vite build", + "build": "tsc --noEmit && vite build", "preview": "vite preview", "check": "svelte-check --tsconfig ./tsconfig.json" }, diff --git a/lix/packages/server/package.json b/lix/packages/server/package.json index 79d6126381..85c2c71193 100644 --- a/lix/packages/server/package.json +++ b/lix/packages/server/package.json @@ -12,7 +12,7 @@ ], "scripts": { "build": "tsc --build", - "test": "tsc --noEmit && vitest run --passWithNoTests --coverage", + "test": "vitest run --passWithNoTests --coverage", "dev": "node --loader tsx ./src/main.ts", "production": "NODE_ENV=production NODE_OPTIONS=--max-old-space-size=500 tsx ./src/main.ts", "lint": "eslint ./src --fix", From 98da21b2968476d93010d90fa2b097a615b5a44c Mon Sep 17 00:00:00 2001 From: LorisSigrist Date: Wed, 17 Apr 2024 17:31:29 +0200 Subject: [PATCH 02/11] Typecheck after building --- .../paraglide/paraglide-js-adapter-vite/example/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inlang/source-code/paraglide/paraglide-js-adapter-vite/example/package.json b/inlang/source-code/paraglide/paraglide-js-adapter-vite/example/package.json index 64195f900c..5b3b7778b6 100644 --- a/inlang/source-code/paraglide/paraglide-js-adapter-vite/example/package.json +++ b/inlang/source-code/paraglide/paraglide-js-adapter-vite/example/package.json @@ -5,7 +5,7 @@ "type": "module", "scripts": { "_dev": "vite dev", - "build": "tsc --noEmit && vite build", + "build": "vite build && tsc --noEmit", "clean": "rm -rf ./dist ./node_modules ./src/paraglide" }, "devDependencies": { From d981f6d3a2d35dfd07429eba863fdc819cac8440 Mon Sep 17 00:00:00 2001 From: LorisSigrist Date: Wed, 17 Apr 2024 17:32:19 +0200 Subject: [PATCH 03/11] Typecheck website after building --- inlang/source-code/website/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inlang/source-code/website/package.json b/inlang/source-code/website/package.json index 8168ac1b12..c0b0b3dfb6 100644 --- a/inlang/source-code/website/package.json +++ b/inlang/source-code/website/package.json @@ -4,7 +4,7 @@ "private": true, "scripts": { "dev": "vite", - "build": "node ./scripts/generateSitemap.js && npx @inlang/cli machine translate -f --project ../../../project.inlang --targetLanguageTags fr,it,pt-BR,sk,zh && tsc --noEmit && vite build", + "build": "node ./scripts/generateSitemap.js && npx @inlang/cli machine translate -f --project ../../../project.inlang --targetLanguageTags fr,it,pt-BR,sk,zh && vite build && tsc --noEmit", "production": "NODE_ENV=production tsx ./src/server/main.ts ", "---- TEST ----------------------------------------------------------": "", "test": "paraglide-js compile --project ../../../project.inlang && npx @inlang/cli lint --project ../../../project.inlang --languageTags de,en ", From b68287a32095e29a62139b1380b77df65c0f8ae4 Mon Sep 17 00:00:00 2001 From: LorisSigrist Date: Wed, 17 Apr 2024 17:41:29 +0200 Subject: [PATCH 04/11] Typecheck after compiling --- inlang/source-code/editor/package.json | 2 +- .../paraglide/paraglide-js-adapter-webpack/example/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/inlang/source-code/editor/package.json b/inlang/source-code/editor/package.json index 06d708692a..fe71007aae 100644 --- a/inlang/source-code/editor/package.json +++ b/inlang/source-code/editor/package.json @@ -4,7 +4,7 @@ "private": true, "scripts": { "dev": "vite", - "build": "paraglide-js compile --project ../../../project.inlang && tsc --noEmit && vite build -- --max_old_space_size=1200000", + "build": "vite build -- --max_old_space_size=1200000 && tsc --noEmit", "production": "NODE_ENV=production tsx ./src/server/main.ts", "---- TEST ----------------------------------------------------------": "", "test": "paraglide-js compile --project ../../../project.inlang", diff --git a/inlang/source-code/paraglide/paraglide-js-adapter-webpack/example/package.json b/inlang/source-code/paraglide/paraglide-js-adapter-webpack/example/package.json index 6da3e0d24e..8e18bb5a79 100644 --- a/inlang/source-code/paraglide/paraglide-js-adapter-webpack/example/package.json +++ b/inlang/source-code/paraglide/paraglide-js-adapter-webpack/example/package.json @@ -4,7 +4,7 @@ "version": "0.0.0", "type": "module", "scripts": { - "build": "tsc --noEmit && webpack --config webpack.config.js", + "build": "webpack --config webpack.config.js && tsc --noEmit", "clean": "rm -rf ./dist ./node_modules ./src/paraglide" }, "devDependencies": { From 2f2201fc96f5afe4707d1d173b6cea73428f0a38 Mon Sep 17 00:00:00 2001 From: LorisSigrist Date: Wed, 17 Apr 2024 17:48:34 +0200 Subject: [PATCH 05/11] Typecheck rollup after build --- .../example/package.json | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/inlang/source-code/paraglide/paraglide-js-adapter-rollup/example/package.json b/inlang/source-code/paraglide/paraglide-js-adapter-rollup/example/package.json index c5c8266b0e..3fe7310833 100644 --- a/inlang/source-code/paraglide/paraglide-js-adapter-rollup/example/package.json +++ b/inlang/source-code/paraglide/paraglide-js-adapter-rollup/example/package.json @@ -1,17 +1,17 @@ { - "name": "@inlang/paraglide-js-adapter-rollup-example", - "private": true, - "version": "0.0.0", - "type": "module", - "scripts": { - "build": "tsc --noEmit && rollup src/main.js --config rollup.config.js", - "clean": "rm -rf ./dist ./node_modules ./src/paraglide" - }, - "devDependencies": { - "@inlang/paraglide-js": "workspace:*", - "@inlang/paraglide-js-adapter-rollup": "workspace:*", - "rollup": "3.29.1", - "@rollup/plugin-alias": "^5.0.1", - "typescript": "^4.9.3" - } + "name": "@inlang/paraglide-js-adapter-rollup-example", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "build": "rollup src/main.js --config rollup.config.js && tsc --noEmit", + "clean": "rm -rf ./dist ./node_modules ./src/paraglide" + }, + "devDependencies": { + "@inlang/paraglide-js": "workspace:*", + "@inlang/paraglide-js-adapter-rollup": "workspace:*", + "rollup": "3.29.1", + "@rollup/plugin-alias": "^5.0.1", + "typescript": "^4.9.3" + } } \ No newline at end of file From fd1ae05e496af795879b40efb5528cf8316a9ae7 Mon Sep 17 00:00:00 2001 From: LorisSigrist Date: Wed, 17 Apr 2024 17:54:57 +0200 Subject: [PATCH 06/11] Remove typechecking from astro as `astro check` already does that --- .../paraglide/paraglide-js-adapter-astro/example/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inlang/source-code/paraglide/paraglide-js-adapter-astro/example/package.json b/inlang/source-code/paraglide/paraglide-js-adapter-astro/example/package.json index 62a0ed5977..51461cf155 100644 --- a/inlang/source-code/paraglide/paraglide-js-adapter-astro/example/package.json +++ b/inlang/source-code/paraglide/paraglide-js-adapter-astro/example/package.json @@ -6,7 +6,7 @@ "scripts": { "_dev": "astro dev", "start": "astro dev", - "build": "paraglide-js compile --project ./project.inlang && tsc --noEmit && astro check && astro build", + "build": "paraglide-js compile --project ./project.inlang && astro check && astro build", "preview": "astro preview", "astro": "astro" }, From 1919cd736a6f9c4801209b2cea9c24a6795682b3 Mon Sep 17 00:00:00 2001 From: LorisSigrist Date: Wed, 17 Apr 2024 17:56:03 +0200 Subject: [PATCH 07/11] Fix tsconfig --- .../paraglide-js-adapter-sveltekit/example/tsconfig.json | 1 - 1 file changed, 1 deletion(-) diff --git a/inlang/source-code/paraglide/paraglide-js-adapter-sveltekit/example/tsconfig.json b/inlang/source-code/paraglide/paraglide-js-adapter-sveltekit/example/tsconfig.json index a201991136..6ae0c8c44d 100644 --- a/inlang/source-code/paraglide/paraglide-js-adapter-sveltekit/example/tsconfig.json +++ b/inlang/source-code/paraglide/paraglide-js-adapter-sveltekit/example/tsconfig.json @@ -7,7 +7,6 @@ "forceConsistentCasingInFileNames": true, "resolveJsonModule": true, "skipLibCheck": true, - "moduleResolution": "Bundler", "sourceMap": true, "strict": true } From b384282cded26db64c1d05ba7a193e774b0921a5 Mon Sep 17 00:00:00 2001 From: LorisSigrist Date: Wed, 17 Apr 2024 17:59:40 +0200 Subject: [PATCH 08/11] Fix SvelteKit build --- .../paraglide-js-adapter-sveltekit/example/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inlang/source-code/paraglide/paraglide-js-adapter-sveltekit/example/package.json b/inlang/source-code/paraglide/paraglide-js-adapter-sveltekit/example/package.json index 266b36ff82..7f5c13f23a 100644 --- a/inlang/source-code/paraglide/paraglide-js-adapter-sveltekit/example/package.json +++ b/inlang/source-code/paraglide/paraglide-js-adapter-sveltekit/example/package.json @@ -5,7 +5,7 @@ "scripts": { "_dev": "vite dev", "start": "vite dev", - "build": "paraglide-js compile --project ./project.inlang && tsc --noEmit && vite build", + "build": "vite build && tsc --noEmit", "test": "vite build", "preview": "vite preview", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", From ed0a4d2ef5794d0edf2c5a2977ed57641a2a34b4 Mon Sep 17 00:00:00 2001 From: LorisSigrist Date: Wed, 17 Apr 2024 18:05:29 +0200 Subject: [PATCH 09/11] Ingore unrelated tsconfig errors when building paragldie --- inlang/source-code/paraglide/paraglide-js/vite.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inlang/source-code/paraglide/paraglide-js/vite.config.js b/inlang/source-code/paraglide/paraglide-js/vite.config.js index 52c1177c47..e0d1718e1d 100644 --- a/inlang/source-code/paraglide/paraglide-js/vite.config.js +++ b/inlang/source-code/paraglide/paraglide-js/vite.config.js @@ -5,7 +5,7 @@ import pkg from "./package.json" import manifest from "./marketplace-manifest.json" export default defineConfig(({ mode }) => ({ - plugins: [dts({ insertTypesEntry: true }), tsconfigPaths()], + plugins: [dts({ insertTypesEntry: true, ignoreConfigErrors: true }), tsconfigPaths()], build: { lib: { entry: ["src/index.ts", "src/adapter-utils/index.ts", "src/cli/index.ts"], From 946be929425eccc9ce2d46b17b2030457f3d0ff0 Mon Sep 17 00:00:00 2001 From: LorisSigrist Date: Thu, 18 Apr 2024 08:29:54 +0200 Subject: [PATCH 10/11] Fix aliases --- inlang/source-code/paraglide/paraglide-js/src/cli/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inlang/source-code/paraglide/paraglide-js/src/cli/index.ts b/inlang/source-code/paraglide/paraglide-js/src/cli/index.ts index 0133abf438..af70a31046 100644 --- a/inlang/source-code/paraglide/paraglide-js/src/cli/index.ts +++ b/inlang/source-code/paraglide/paraglide-js/src/cli/index.ts @@ -1,6 +1,6 @@ import { Command } from "commander" -import { compileCommand } from "~/cli/commands/compile/command.js" -import { initCommand } from "~/cli/commands/init/command.js" +import { compileCommand } from "./commands/compile/command.js" +import { initCommand } from "./commands/init/command.js" export const cli = new Command() .name("paraglide-js") From f63c261f8b98702c3740ee17490b8e79bc1b44cc Mon Sep 17 00:00:00 2001 From: LorisSigrist Date: Thu, 18 Apr 2024 08:50:36 +0200 Subject: [PATCH 11/11] Fiy Next adapter build on windows --- .../paraglide-js-adapter-next/build.mjs | 150 ++++++++---------- .../paraglide-js-adapter-next/package.json | 2 +- .../paraglide-js-adapter-next/plugins.mjs | 29 ++++ .../vitest.config.mjs | 2 +- 4 files changed, 95 insertions(+), 88 deletions(-) create mode 100644 inlang/source-code/paraglide/paraglide-js-adapter-next/plugins.mjs diff --git a/inlang/source-code/paraglide/paraglide-js-adapter-next/build.mjs b/inlang/source-code/paraglide/paraglide-js-adapter-next/build.mjs index d32997d6c7..c51133ae87 100644 --- a/inlang/source-code/paraglide/paraglide-js-adapter-next/build.mjs +++ b/inlang/source-code/paraglide/paraglide-js-adapter-next/build.mjs @@ -1,10 +1,5 @@ import { rollup } from "rollup" -import preserveDirectives from "rollup-preserve-directives" -import typescript from "@rollup/plugin-typescript" -import cjs from "@rollup/plugin-commonjs" -import json from "@rollup/plugin-json" -import resolve from "@rollup/plugin-node-resolve" -import replace from "@rollup/plugin-replace" +import { plugins } from "./plugins.mjs" import fs from "node:fs/promises" //remove the old dist folder @@ -18,93 +13,76 @@ if (typeof version !== "string") { const peerDependencies = Object.keys(packageJson.peerDependencies || {}) const dependencies = Object.keys(packageJson.dependencies || {}) -export const plugins = [ - typescript({ tsconfig: "./tsconfig.json" }), - cjs(), - resolve(), - preserveDirectives(), - json(), - replace({ - values: { - MARKETPLACE_ID: JSON.stringify("library.inlang.paraglideJsAdapterNextJs"), - PARAGLIDE_NEXT_VERSION: JSON.stringify(version), - }, - preventAssignment: true, - }), -] - // eslint-disable-next-line no-undef -if (process.env.SCRIPT === "build") { - // eslint-disable-next-line no-console - // eslint-disable-next-line no-undef - console.info(`Building ${packageJson.name} v${packageJson.version}...`) +// eslint-disable-next-line no-console +// eslint-disable-next-line no-undef +console.info(`Building ${packageJson.name} v${packageJson.version}...`) - const external = [ - /node_modules/, - /^node:/, - "$paraglide/runtime.js", - ...peerDependencies, - ...dependencies, - ] +const external = [ + /node_modules/, + /^node:/, + "$paraglide/runtime.js", + ...peerDependencies, + ...dependencies, +] - const app_build = await rollup({ - plugins, - input: { - "app/index.server": "src/app/index.server.tsx", - "app/index.client": "src/app/index.client.tsx", - }, - external, - }) +const app_build = await rollup({ + plugins, + input: { + "app/index.server": "src/app/index.server.tsx", + "app/index.client": "src/app/index.client.tsx", + }, + external, +}) - const pages_build = await rollup({ - plugins, - input: { - "pages/index": "src/pages/index.tsx", - }, - external, - }) +const pages_build = await rollup({ + plugins, + input: { + "pages/index": "src/pages/index.tsx", + }, + external, +}) - const pluginBuild = await rollup({ - plugins, - input: { - "plugin/index": "src/plugin/index.ts", - }, - external, - }) +const pluginBuild = await rollup({ + plugins, + input: { + "plugin/index": "src/plugin/index.ts", + }, + external, +}) - const cliBuild = await rollup({ - plugins, - input: { - "cli/index": "src/cli/index.ts", - }, - external: [/^node:/, ...peerDependencies, ...dependencies], - }) +const cliBuild = await rollup({ + plugins, + input: { + "cli/index": "src/cli/index.ts", + }, + external: [/^node:/, ...peerDependencies, ...dependencies], +}) - await app_build.write({ - preserveModules: true, - format: "es", - entryFileNames: "[name].js", - dir: "dist", - }) +await app_build.write({ + preserveModules: true, + format: "es", + entryFileNames: "[name].js", + dir: "dist", +}) - await pages_build.write({ - preserveModules: false, - format: "cjs", - entryFileNames: "[name].js", - dir: "dist", - }) +await pages_build.write({ + preserveModules: false, + format: "cjs", + entryFileNames: "[name].js", + dir: "dist", +}) - await pluginBuild.write({ - preserveModules: false, - format: "cjs", - entryFileNames: "[name].cjs", - dir: "dist", - }) +await pluginBuild.write({ + preserveModules: false, + format: "cjs", + entryFileNames: "[name].cjs", + dir: "dist", +}) - await cliBuild.write({ - preserveModules: true, - format: "esm", - entryFileNames: "[name].mjs", - dir: "dist", - }) -} \ No newline at end of file +await cliBuild.write({ + preserveModules: true, + format: "esm", + entryFileNames: "[name].mjs", + dir: "dist", +}) diff --git a/inlang/source-code/paraglide/paraglide-js-adapter-next/package.json b/inlang/source-code/paraglide/paraglide-js-adapter-next/package.json index 01cdd60c60..39938da773 100644 --- a/inlang/source-code/paraglide/paraglide-js-adapter-next/package.json +++ b/inlang/source-code/paraglide/paraglide-js-adapter-next/package.json @@ -9,7 +9,7 @@ "url": "https://github.com/opral/inlang-paraglide-js" }, "scripts": { - "build": "SCRIPT=build node ./build.mjs", + "build": "node ./build.mjs", "clean": "rm -rf dist && rm -rf node_modules", "test": "NODE_ENV=development vitest run && NODE_ENV=production vitest run", "lint": "eslint ./src --fix" diff --git a/inlang/source-code/paraglide/paraglide-js-adapter-next/plugins.mjs b/inlang/source-code/paraglide/paraglide-js-adapter-next/plugins.mjs new file mode 100644 index 0000000000..a7f733d6ad --- /dev/null +++ b/inlang/source-code/paraglide/paraglide-js-adapter-next/plugins.mjs @@ -0,0 +1,29 @@ +import { rollup } from "rollup" +import preserveDirectives from "rollup-preserve-directives" +import typescript from "@rollup/plugin-typescript" +import cjs from "@rollup/plugin-commonjs" +import json from "@rollup/plugin-json" +import resolve from "@rollup/plugin-node-resolve" +import replace from "@rollup/plugin-replace" +import fs from "node:fs/promises" + +const packageJson = JSON.parse(await fs.readFile("./package.json", "utf-8")) +const version = packageJson.version +if (typeof version !== "string") { + throw new Error("the version in package.json is not a string") +} + +export const plugins = [ + typescript({ tsconfig: "./tsconfig.json" }), + cjs(), + resolve(), + preserveDirectives(), + json(), + replace({ + values: { + MARKETPLACE_ID: JSON.stringify("library.inlang.paraglideJsAdapterNextJs"), + PARAGLIDE_NEXT_VERSION: JSON.stringify(version), + }, + preventAssignment: true, + }), +] diff --git a/inlang/source-code/paraglide/paraglide-js-adapter-next/vitest.config.mjs b/inlang/source-code/paraglide/paraglide-js-adapter-next/vitest.config.mjs index d22c4b4771..17a69fdf9f 100644 --- a/inlang/source-code/paraglide/paraglide-js-adapter-next/vitest.config.mjs +++ b/inlang/source-code/paraglide/paraglide-js-adapter-next/vitest.config.mjs @@ -1,7 +1,7 @@ import { dirname, resolve } from "node:path" import { fileURLToPath } from "node:url" import react from "@vitejs/plugin-react" -import { plugins } from "./build.mjs" +import { plugins } from "./plugins.mjs" const __filename = resolve(fileURLToPath(import.meta.url)) const __dirname = dirname(__filename)