Compile files and directories whose names start with .#1164
Compile files and directories whose names start with .#1164
.#1164Conversation
🦋 Changeset detectedLatest commit: 3431c08 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
template/base/tsconfig.build.json
Outdated
| // Must be explicit about including dotfiles otherwise TypeScript ignores them | ||
| // https://github.com/microsoft/TypeScript/blob/v5.0.4/src/compiler/utilities.ts#L8828-L8830 |
There was a problem hiding this comment.
Thanks for finding this @mrm007. I recall you first mentioned that this affected our esbuild implementation; does it affect tsc too?
If it's esbuild only then I'm hoping we can add some adapter logic to deal with this under the hood.
There was a problem hiding this comment.
Strangely, it's only for esbuild. Running tsc via the command line finds and compiles all files, as expected.
The filter is applied only when resolving the config programmatically.
There was a problem hiding this comment.
Okay wow, this is a great find. It comes down to this and is actually a deeper bug with the esbuild implementation:
skuba/src/cli/build/esbuild.ts
Lines 68 to 82 in 3196eb1
The TypeScript API does not include dot paths when deriving fileNames and this holds true for tsc internally. However, tsc performs module resolution and will subsequently include files like .vocab/index.ts only if they have been imported by another module in fileNames. On the other hand, our esbuild adapter disables bundling and ends up classifying files like .vocab/index.ts as "external" dependencies that should not be included.
There are a few options here:
- Ask consumers to manually modify their
tsconfig.json#includeas per this PR. This is simple but feels like a rather arcane fix. - Use a custom method to derive
fileNamesin theesbuildadapter that includes dot paths by default. This would let us play nicely with Vocab but won't promise to match the TypeScript implementation. - We can read the
metafileout ofesbuildand identify imports that should be included in a second pass.
There was a problem hiding this comment.
What if we do the globbing ourselves and include all the dotfiles? Basically, applying the same technique mentioned here #1163 (comment):
- take the root directory from
skuba.entryPointi.e.srcforsrc/index.ts - find all
*.{ts,tsx,cts,mts}files - compile them with esbuild
Something like this 2c96e5b (#1164)
Found this issue while testing #1163
Before merging:
src/cli/build/esbuild.ts