From 2556bf198688e1952f8d5c35c00a3277e75b3aef Mon Sep 17 00:00:00 2001 From: Derk-Jan Karrenbeld Date: Wed, 31 Jul 2024 21:59:52 +0200 Subject: [PATCH] Use tsconfig.solutions.json --- bin/run.sh | 24 ++++++++++++++---------- tsconfig.json | 3 --- tsconfig.solutions.json | 31 +++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 13 deletions(-) create mode 100644 tsconfig.solutions.json diff --git a/bin/run.sh b/bin/run.sh index 7b6ee18..fdf534a 100755 --- a/bin/run.sh +++ b/bin/run.sh @@ -163,6 +163,10 @@ if [[ "${OUTPUT}" =~ "$ROOT" ]]; then echo "the tests, which is what we want. No need to turn the output " echo "directory into a standalone package." echo "" + + echo "✔️ tsconfig.json from root to output" + cp "${ROOT}/tsconfig.solutions.json" "${OUTPUT}tsconfig.json" + echo "" else echo "" echo "The output directory is likely not placed inside the test " @@ -194,7 +198,7 @@ else cp "${ROOT}/package.json" "${OUTPUT}package.json" echo "✔️ tsconfig.json from root to output" - cp "${ROOT}/tsconfig.json" "${OUTPUT}tsconfig.json" + cp "${ROOT}/tsconfig.solutions.json" "${OUTPUT}tsconfig.json" echo "" fi @@ -313,13 +317,13 @@ set +e # cp -r "$ROOT/node_modules/@types" "$INPUT/node_modules" if test -f "${OUTPUT}tsconfig.json"; then - echo "✔️ found a tsconfig.json (as expected). Re-configuring." + echo "✔️ found a tsconfig.json (as expected)" #. Re-configuring." # replace "include": ["src"], - sed -i 's/"include": \["src"\],/"\/\/ include": ["src"],/' "${OUTPUT}tsconfig.json" + # sed -i 's/"include": \["src"\],/"\/\/ include": ["src"],/' "${OUTPUT}tsconfig.json" # replace "exclude": ["test", "node_modules"] - sed -i 's/"exclude": \["test", "node_modules"\]/"exclude": ["test", "node_modules", ".meta\/*", "__typetests__\/*", "*.test.ts", "*.tst.ts"]/' "${OUTPUT}tsconfig.json" + # sed -i 's/"exclude": \["test", "node_modules"\]/"exclude": ["test", "node_modules", ".meta\/*", "__typetests__\/*", "*.test.ts", "*.tst.ts"]/' "${OUTPUT}tsconfig.json" echo "👁️ ${OUTPUT}tsconfig.json" cat "${OUTPUT}tsconfig.json" @@ -333,15 +337,15 @@ test_exit=$? echo "$tsc_result" > $result_file -if test -f "${OUTPUT}tsconfig.json"; then - echo "✔️ found a tsconfig.json (as expected). Restoring." +# if test -f "${OUTPUT}tsconfig.json"; then + # echo "✔️ found a tsconfig.json (as expected). Restoring." - # replace "include": ["src"], - sed -i 's/"\/\/ include": \["src"\],/"include": ["src"],/' "${OUTPUT}tsconfig.json" + # replace "include": ["src"], + # sed -i 's/"\/\/ include": \["src"\],/"include": ["src"],/' "${OUTPUT}tsconfig.json" # replace "exclude": ["test", "node_modules"] - sed -i 's/"exclude": \["test", "node_modules", ".meta\/*", "__typetests__\/*", "*.test.ts", "*.tst.ts"\]/"exclude": ["test", "node_modules"]/' "${OUTPUT}tsconfig.json" -fi; + # sed -i 's/"exclude": \["test", "node_modules", ".meta\/*", "__typetests__\/*", "*.test.ts", "*.tst.ts"\]/"exclude": ["test", "node_modules"]/' "${OUTPUT}tsconfig.json" +# fi; if [ $test_exit -eq 2 ]; then echo "" diff --git a/tsconfig.json b/tsconfig.json index 6f8c959..750ec45 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,8 +1,5 @@ { "extends": "@tsconfig/node20/tsconfig.json", - "compilerOptions": { - "allowImportingTsExtensions": true - }, "include": ["src"], "exclude": ["test", "node_modules"] } diff --git a/tsconfig.solutions.json b/tsconfig.solutions.json new file mode 100644 index 0000000..23fc994 --- /dev/null +++ b/tsconfig.solutions.json @@ -0,0 +1,31 @@ +{ + "extends": "@tsconfig/node20/tsconfig.json", + "compilerOptions": { + // Allows you to use the newest syntax, and have access to console.log + // https://www.typescriptlang.org/tsconfig#lib + "lib": ["ES2020", "dom"], + // Make sure typescript is configured to output ESM + // https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c#how-can-i-make-my-typescript-project-output-esm + "module": "Node16", + // Since this project is using babel, TypeScript may target something very + // high, and babel will make sure it runs on your local Node version. + // https://babeljs.io/docs/en/ + "target": "ES2020", // ESLint doesn't support this yet: "es2022", + + "strict": true, + "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + + // Because jest-resolve isn't like node resolve, the absolute path must be .ts + "allowImportingTsExtensions": true, + "noEmit": true, + + // Because we'll be using babel: ensure that Babel can safely transpile + // files in the TypeScript project. + // + // https://babeljs.io/docs/en/babel-plugin-transform-typescript/#caveats + "isolatedModules": true + }, + "exclude": [".meta/*", "__typetests__/*", "*.test.ts", "*.tst.ts"] +}