-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compile files and directories whose names start with .
#1164
base: main
Are you sure you want to change the base?
Conversation
🦋 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
const parsedCommandLine = ts.parseJsonConfigFileContent( | |
readConfigFile.config, | |
ts.sys, | |
tscArgs.dirname, | |
); | |
if (parsedCommandLine.errors.length) { | |
log.err(`Could not parse ${tscArgs.pathname}.`); | |
log.subtle(ts.formatDiagnostics(parsedCommandLine.errors, formatHost)); | |
process.exitCode = 1; | |
return; | |
} | |
const { fileNames: entryPoints, options: compilerOptions } = | |
parsedCommandLine; |
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#include
as per this PR. This is simple but feels like a rather arcane fix. - Use a custom method to derive
fileNames
in theesbuild
adapter 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
metafile
out ofesbuild
and identify imports that should be included in a second pass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.entryPoint
i.e.src
forsrc/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