-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
fix: Reflect the configuration for esbuild #12676
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 3d58791 The changes in this PR will be included in the next version bump. 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 |
...compileProps.viteConfig.esbuild, | ||
loader: 'ts', | ||
target: 'esnext', |
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.
Since the default target in esbuild is esnext, the explicit specification has been removed.
(If the user does not specify vite.esbuild
in the astro config, compileProps.viteConfig.esbuild
will be undefined
, and the default settings of esbuild will be applied)
https://esbuild.github.io/api/#target:~:text=The%20default%20target%20is%20esnext
CodSpeed Performance ReportMerging #12676 will not alter performanceComparing Summary
|
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.
Works for me 👍 I don't know if we can always guarantee that the Astro TS will always be affected by vite.esbuild
, since TypeScript compilation within Astro is an implementation detail, but since we had use the API for long now I think this should be fine.
async function compile(source, id) { | ||
const viteConfig = await resolveConfig({ configFile: false, ...inlineConfig }, 'serve'); |
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.
Can we pass the inlineConfig
as a parameter of compile
instead? That way we avoid passing the global around.
Changes
I modified compileAstro to reflect the settings in viteConfig.esbuild.
This change ensures that when
vite.esbuild.target
is specified in the Astro config, it is reflected during the compilation of Astro files. Previously, while thevite.build.target
value would affect thebuild
command output of an Astro project, it did not impact thedev
command output. As a result, the esbuild target was effectively fixed toesnext
. This update addresses and resolves that issue.For example, by setting the configuration as follows, you can specify the esbuild target during the compilation of Astro files.
Fixes: The vite.build.target setting does not take effect in dev mode. · Issue #12655
Testing
Added tests with code that includes syntax targeted by esbuild, confirming the following two points:
esbuild.target
is not present in ViteConfig.esbuild.target
is specified as anything other thanesnext
in ViteConfig.esbuild.target
set toes2018
.Docs
No documentation changes are necessary.