Fix adapter-node build in presence of tsconfig.json #1675
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1667 in a way that (as far as I can tell) does not break compatibility with Node 12.
In Kit apps written in TypeScript, esbuild was seeing the
tsconfig.json
in the user's app and thetarget
in there was being used since the call toesbuild.build()
did not explicitly specify one. This was a problem because the starter app useses2019
, which does not supportimport.meta.url
, and so the references to this (including the ones in the code introduced by the adapter) were being replaced withundefined
.We don't want to tell the adapter to bundle for
target: 'es2020'
because that would then mean we wouldn't be transpiling features not supported by Node 12. Luckily, esbuild lets us dotarget: 'node12'
, which transpiles specifically the features not supported in Node 12. This lets us use?.
(which will get transpiled) and also useimport.meta.url
(which is left as-is since it is supported natively in Node 12, even though it doesn't support all of ES2020).Before submitting the PR, please make sure you do the following
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpx changeset
and following the prompts