Node's --strip-types does not rewrite import specifiers the way bundlers and Deno do, so 'import ... from "./match.js"' literally looks for match.js (not match.ts) and fails with ERR_MODULE_NOT_FOUND at test time. Fix by switching source imports to .ts extensions and letting TypeScript's rewriteRelativeImportExtensions do the rewrite at build emit time. Changes: - tsconfig.json: enable allowImportingTsExtensions (works because the root config has noEmit: true) - tsconfig.build.json: enable rewriteRelativeImportExtensions so the emitted dist/*.js files keep './match.js' style imports (correct for consumers), not './match.ts' - src/index.ts: import './match.ts' and './pattern.ts' - src/match.ts: import './pattern.ts' - src/index.test.ts: import './index.ts' Verified: npm run test runs tsc --noEmit (passes) and node --test --strip-types src/ — all 6 tests pass. tsc -p tsconfig.build.json emits dist/*.js with './match.js' imports as before; consumers see no change.
39 lines
1.2 KiB
JSON
39 lines
1.2 KiB
JSON
{
|
|
"compilerOptions": {
|
|
"target": "es2024",
|
|
"module": "nodenext",
|
|
"moduleResolution": "nodenext",
|
|
"moduleDetection": "force",
|
|
"lib": ["es2024"],
|
|
"skipLibCheck": true,
|
|
"strict": true,
|
|
"noImplicitAny": true,
|
|
"noImplicitThis": true,
|
|
"alwaysStrict": true,
|
|
"strictNullChecks": true,
|
|
"strictFunctionTypes": true,
|
|
"strictBindCallApply": true,
|
|
"strictPropertyInitialization": true,
|
|
"noImplicitReturns": true,
|
|
"noFallthroughCasesInSwitch": true,
|
|
"noUncheckedIndexedAccess": true,
|
|
"noImplicitOverride": true,
|
|
"forceConsistentCasingInFileNames": true,
|
|
"noUnusedLocals": true,
|
|
"noUnusedParameters": true,
|
|
"isolatedModules": true,
|
|
"verbatimModuleSyntax": true,
|
|
"allowImportingTsExtensions": true,
|
|
"declaration": true,
|
|
"declarationMap": true,
|
|
"sourceMap": true,
|
|
"outDir": "dist",
|
|
"esModuleInterop": true,
|
|
"allowSyntheticDefaultImports": true,
|
|
"resolveJsonModule": true,
|
|
"composite": false,
|
|
"types": ["node"]
|
|
},
|
|
"include": ["src"]
|
|
}
|