Skip to content

fix(astro): preserve quoted import specifiers when appending asset query params#16207

Closed
auroursa wants to merge 2 commits into
withastro:mainfrom
auroursa:fix/plugin-chunk-imports.ts
Closed

fix(astro): preserve quoted import specifiers when appending asset query params#16207
auroursa wants to merge 2 commits into
withastro:mainfrom
auroursa:fix/plugin-chunk-imports.ts

Conversation

@auroursa
Copy link
Copy Markdown

@auroursa auroursa commented Apr 3, 2026

Fixes #16196

This seems likely connected to #16110, which introduced inter-chunk import rewriting for adapter asset query params.

Deployment Failure on Netlify

[ERROR] [vite] ✗ Build failed in 360ms
Syntax error "c"
  Location:
    _astro/page.!~{007}~.js:17:50

Changes

  • Fix plugin-chunk-imports rewrite logic to preserve valid JS import syntax when appending assetQueryParams.
  • Rewrite only the module specifier content (inside quotes) using es-module-lexer offsets, instead of inserting blindly at the previous end offset.
  • Merge adapter-provided query params with existing ?query and #hash in relative inter-chunk JS imports.
  • Add clarifying inline comments around specifier offsets and param snapshot behavior.
  • This addresses cloud-only build failures (e.g. Netlify/Vercel) where generated _astro/*.js could become syntactically invalid in downstream bundling.

Testing

  • Reproduced the issue on Netlify before this fix (deployment build failed with syntax errors in generated _astro/*.js chunks).
  • After applying this fix, redeployed the same project on Netlify and confirmed the build now succeeds.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 3, 2026

🦋 Changeset detected

Latest commit: c6b3ff4

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

@github-actions github-actions Bot added the pkg: astro Related to the core `astro` package (scope) label Apr 3, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 3, 2026

Merging this PR will not alter performance

✅ 18 untouched benchmarks


Comparing auroursa:fix/plugin-chunk-imports.ts (c6b3ff4) with main (21f9fe2)

Open in CodSpeed

@tristantbg
Copy link
Copy Markdown

When will this patch be released ?

briandadams85 added a commit to BrianDAdamsDevland/bdadamsdotcom that referenced this pull request Apr 11, 2026
Astro 6.1.3 introduced a bug (withastro/astro#16196, #16209) in the
pluginChunkImports plugin that corrupts dynamic import specifiers on
Netlify/Linux builds when DEPLOY_ID is set. This causes esbuild to
fail with syntax errors on unresolved Rollup hash placeholders.

The fix (withastro/astro#16207) has not been released yet. Pinning to
6.1.2 avoids the regression and removes the minification workaround.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@chocobuckle
Copy link
Copy Markdown

Eagerly waiting for this fix. Netlify builds are failing in the meantime.

@ematipico ematipico closed this Apr 16, 2026
@ematipico
Copy link
Copy Markdown
Member

I fixed it in another PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: astro Related to the core `astro` package (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vite Build fail on Netlify Server

4 participants