Closed yharaskrik closed 1 month ago
Thanks for reporting @yharaskrik - we'll investigate and get back to you.
Thanks for reporting @yharaskrik - we'll investigate and get back to you.
Thank you! I appreciate it, this is the command I am running.
bun run node_modules/typescript/bin/tsc --project apps/aurora/tsconfig.app.json --noEmit --explainFiles > tmp/explain
Tsconfig
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"types": ["node"],
"emitDecoratorMetadata": true,
"target": "esnext",
"verbatimModuleSyntax": true
},
"exclude": ["src/**/*.spec.ts", "src/**/*.test.ts"],
"include": ["src/**/*.ts"]
}
Base tsconfig
"noImplicitReturns": true,
"noImplicitOverride": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"noUnusedLocals": true,
"downlevelIteration": true,
"sourceMap": true,
"allowJs": true,
"declaration": false,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"target": "es2015",
"esModuleInterop": true,
"module": "esnext",
"typeRoots": ["node_modules/@types"],
"lib": ["es2017", "dom", "es2019", "es2020.Promise", "esnext", "webworker"],
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"resolveJsonModule": true,
"useDefineForClassFields": false,
"baseUrl": ".",
Is there a reason the source files are shipped with the package and not just the .js
and .d.ts
?
Is there a reason the source files are shipped with the package and not just the .js and .d.ts?
Mostly to make debugging easier. I think we still need to enable the "ts sourcemaps" though.
It's unclear to me with your provided setup is processing TypeScript files in node_modules, as that is not the default for TypeScript files. I wonder if the issue is bun itself, which I think prefers the .ts
extension over others.
Is there a reason the source files are shipped with the package and not just the .js and .d.ts?
Mostly to make debugging easier. I think we still need to enable the "ts sourcemaps" though.
It's unclear to me with your provided setup is processing TypeScript files in node_modules, as that is not the default for TypeScript files. I wonder if the issue is bun itself, which I think prefers the
.ts
extension over others.
I am only using bun as the runner (instead of node) and calling tsc. So it shouldn't have anything to do with how tsc is resolving the files but I can try without it. I am sure I'll get the same result.
I can try without it.
Yes, please try it without. 🙏 The tsc
compiler does not traverse node_modules
unless explicitly specified in the include
configuration, so we shouldn't see it try to compile the .ts
files.
I'm okay with updating our TypeScript source for verbatimModuleSyntax
since it only seems like we're marking types explicitly as type
.
However, your base config also sets "noUnusedLocals": true
and "noImplicitOverride": true
which I don't think we're going to support. We leverage https://www.typescriptlang.org/docs/handbook/2/narrowing.html#exhaustiveness-checking to check our switch statements which means the .ts
files contain the extra variable while the .js
output does not.
Ok i figured it out, it was not a bun issue, and isn't an issue for a modern version of tsc
, I have a secondary version of typescript
installed (for legacy reasons I am trying to remove). Looks like the version of tsc
in the node_modules/.bin
folder was the old one not the new one, when I run with
bun run node_modules/typescript/bin/tsc --project apps/aurora/tsconfig.app.json --noEmit
or
node --max-old-space-size=8192 node_modules/typescript/bin/tsc --project apps/aurora/tsconfig.app.json --noEmit
It does not happen.
You are absolutely right that it should not be traversing node_modules.
This can now be closed!
Note: looks like its back, our CI just failed with it (even though it passed locally earlier). I will keep trying to dig into it as it absolutely should not be doing this, super weird, but I want to use arcjet.
Not shipping the source files would fix it, but that change shouldn't be needed (I suspect none of our other packages are shipping source files and thats why we haven't run into this before)
I just installed the Arcjet SDK to use in our Nest application as a global guard but when I run the TS compilation with the
verbatimModuleSyntax
flag I getIt looks like TS is not able to find the .js/.d.ts files and instead reverting to building from source? I am importing arcjet just like the examples
import arcjet, { detectBot, slidingWindow } from '@arcjet/node';
So it should just work, has anyone else seen this happen?
here is the output from using
--explainFiles
, I have never seen source like this get included in a build.This looks like the key part, the arcjet/protocol, index.ts is being included in the build from a JS file.