From 1e0ddf9c2010e330e2500fbedcd42f4f064b0b8d Mon Sep 17 00:00:00 2001 From: Serhii Kulykov Date: Tue, 16 Jan 2024 09:54:22 +0200 Subject: [PATCH] feat: add script to build type definitions for theme folders (#7087) --- .eslintignore | 1 + .gitignore | 3 +++ package.json | 3 ++- scripts/buildThemeTypings.sh | 16 ++++++++++++++++ tsconfig.build.json | 12 ++++++++++++ 5 files changed, 34 insertions(+), 1 deletion(-) create mode 100755 scripts/buildThemeTypings.sh create mode 100644 tsconfig.build.json diff --git a/.eslintignore b/.eslintignore index 1a6f7badd0..4201bc3531 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,3 +1,4 @@ packages/**/vendor/*.js packages/**/dist/*.js packages/**/test/dom/__snapshots__/*.snap.js +packages/**/theme/**/*.d.ts diff --git a/.gitignore b/.gitignore index 6b5e1996d2..785c6748d1 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,9 @@ yarn-error.log packages/*/test/visual/*/screenshots/*/failed packages/icons/test/visual/screenshots/failed +# Generated theme folders .ts files +packages/**/theme/**/*.d.ts + # MacOS DS_Store files .DS_Store diff --git a/package.json b/package.json index 7dccf7ca6b..8119a33f30 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,8 @@ "private": true, "author": "Vaadin Ltd", "scripts": { - "analyze": "polymer analyze packages/**/vaadin-*.js > analysis.json && node scripts/prepareDocs.js && node scripts/buildWebtypes.js && node scripts/generateLumoAutoCompleteCss.js", + "analyze": "polymer analyze packages/**/vaadin-*.js > analysis.json && node scripts/prepareDocs.js && node scripts/buildWebtypes.js && node scripts/generateLumoAutoCompleteCss.js && ./scripts/buildThemeTypings.sh", + "build:ts": "tsc --build tsconfig.build.json", "debug": "web-test-runner --watch", "debug:it": "web-test-runner --watch --config web-test-runner-it.config.js", "dist": "rimraf dist && yarn analyze && rollup -c rollup.config.js && cp analysis.json dist", diff --git a/scripts/buildThemeTypings.sh b/scripts/buildThemeTypings.sh new file mode 100755 index 0000000000..ce77e2d377 --- /dev/null +++ b/scripts/buildThemeTypings.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +# Rename .js files to .ts +for file in packages/**/theme/**/*.js +do + mv "$file" "${file%.js}.ts" +done + +# Build type definitions +npm run build:ts + +# Restore original .js files +git checkout packages/**/theme/**/*.js + +# Remove .ts files but keep .d.ts +find . -path "./packages/*/theme/*.ts" ! -name "*.d.ts" -type f -delete diff --git a/tsconfig.build.json b/tsconfig.build.json new file mode 100644 index 0000000000..efe8eba238 --- /dev/null +++ b/tsconfig.build.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "target": "esnext", + "module": "esnext", + "moduleResolution": "node", + "lib": ["esnext", "es2018", "dom"], + "declaration": true, + "strict": true, + "skipDefaultLibCheck": true + }, + "include": ["packages/**/theme"] +}