Last active
August 23, 2023 07:24
-
-
Save WhereJuly/f60d4e45b1b6d39552f2a35600b2f792 to your computer and use it in GitHub Desktop.
Making node-tap working with TypeScript & `"type": "module"` in package.json (2023-08) (no artificial .js extensions for actual .ts fiiles)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"type": "module", | |
"test": "tap", | |
"devDependencies": { | |
"@esbuild-kit/esm-loader": "^2.5.5", | |
"@swc/core": "^1.3.77", | |
"@tsconfig/node18": "^18.2.0", | |
"@types/node": "^20.5.0", | |
"@types/tap": "^15.0.8", | |
"tap": "^16.3.8", | |
"ts-node": "^10.9.1", | |
"tsconfig-paths": "^4.2.0", | |
"typescript": "^5.1.6" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"extends": "@tsconfig/node18/tsconfig.json", | |
"compilerOptions": { | |
/* Projects */ | |
"incremental": true /* Save .tsbuildinfo files to allow for incremental compilation of projects. */, | |
"tsBuildInfoFile": "./.delivery/.temp/.tsbuildinfo" /* Specify the path to .tsbuildinfo incremental compilation file. */, | |
/* Language and Environment */ | |
"target": "es2022" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, | |
"experimentalDecorators": true /* Enable experimental support for legacy experimental decorators. */, | |
"emitDecoratorMetadata": true /* Emit design-type metadata for decorated declarations in source files. */, | |
/* Modules */ | |
"module": "es2022" /* Specify what module code is generated. */, | |
"moduleResolution": "node" /* Specify how TypeScript looks up a file from a given module specifier. */, | |
"baseUrl": ".", | |
"paths": { | |
"@root/*": ["./*"], | |
"@src/*": ["./src/*"], | |
}, | |
"resolveJsonModule": true /* Enable importing .json files. */, | |
/* Interop Constraints */ | |
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */, | |
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */, | |
/* Type Checking */ | |
"strict": true /* Enable all strict type-checking options. */, | |
/* Completeness */ | |
"skipLibCheck": true /* Skip type checking all .d.ts files. */ | |
}, | |
"ts-node": { | |
"transpileOnly": true, | |
"files": true, | |
"swc": true, | |
"esm": true, | |
"require": ["tsconfig-paths/register"] | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ts: true | |
reporter: spec | |
coverage: false | |
node-arg: | |
# This loader is what did the trick | |
- --loader=@esbuild-kit/esm-loader | |
nyc-arg: | |
- --report-dir="./tests/coverage" | |
- --temp-dir="./tests/.temp/.nyc-output" | |
files: | |
- "./tests/**/*.test.ts" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment