Skip to content

Commit

Permalink
Use tsconfig.solutions.json
Browse files Browse the repository at this point in the history
  • Loading branch information
SleeplessByte committed Jul 31, 2024
1 parent f55468c commit 2556bf1
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 13 deletions.
24 changes: 14 additions & 10 deletions bin/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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"
Expand All @@ -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 ""
Expand Down
3 changes: 0 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"extends": "@tsconfig/node20/tsconfig.json",
"compilerOptions": {
"allowImportingTsExtensions": true
},
"include": ["src"],
"exclude": ["test", "node_modules"]
}
31 changes: 31 additions & 0 deletions tsconfig.solutions.json
Original file line number Diff line number Diff line change
@@ -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"]
}

0 comments on commit 2556bf1

Please sign in to comment.