Skip to content

fix(server-bundle): keep the with key on externalized icon JSON imports - #523

Merged
antfu merged 1 commit into
nuxt:mainfrom
agantelin:fix/import-attributes-key
Aug 10, 2026
Merged

fix(server-bundle): keep the with key on externalized icon JSON imports#523
antfu merged 1 commit into
nuxt:mainfrom
agantelin:fix/import-attributes-key

Conversation

@agantelin

Copy link
Copy Markdown
Contributor

🔗 Linked issue

Resolves #522

📚 Description

externalizeIconsJson generates import('@iconify-json/…/icons.json', { with: { type: 'json' } })
(src/bundle-server.ts:57), but Rollup 4 re-prints the attributes of external modules with its own
default key, assert — and Node.js removed assert in v22, so the icon API 500s with
ERR_IMPORT_ATTRIBUTE_MISSING while the build stays green. Same user-visible error as #186, which
#187 fixed by adding the attribute; this time it's written correctly and lost downstream.

Rollup only flips that default in v5 (rollup/rollup#6248, merged to rollup-5, unreleased). Nitro
has the same gap and I've filed nitrojs/nitro#4518 for it, but a fix there won't reach anyone on a
released Nitro — and this module is the one that creates the external import. So it sets the key
itself, from the plugin it already installs, via outputOptions: ||= leaves an explicit user
setting alone, it works whether the build has one output or several, and nothing outside this
plugin is touched.

After this, the README's promise — "in the final build, it will contain statements like
() => import('@iconify-json/ph/icons.json', { with: { type: 'json' } })" — holds again.

Verification

In playgrounds/nuxt, with serverBundle: { externalizeIconsJson: true } and pnpm play:build:

# before
.output/server/chunks/_/nitro.mjs: import('@iconify-json/ph/icons.json', { assert: { type: 'json' } })
# after
.output/server/chunks/_/nitro.mjs: import('@iconify-json/ph/icons.json', { with: { type: 'json' } })

The underlying Rollup/Nitro behaviour, on plain Nitro without Nuxt (so the 500 and the 200 are easy
to see): https://github.com/agantelin/nitro-import-attributes-repro

No unit test: the hook this touches is the nitro:config one, which the current suite doesn't
exercise, and the playground build above is the honest check. Glad to add one if you'd like it
covered.

@pkg-pr-new

pkg-pr-new Bot commented Aug 9, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/@nuxt/icon@523

commit: dc36a7c

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 29f3e917-3c5e-419c-9f60-8c3cc008de8c

📥 Commits

Reviewing files that changed from the base of the PR and between e062607 and dc36a7c.

📒 Files selected for processing (1)
  • src/module.ts

📝 Walkthrough

Walkthrough

The module adds a Rollup outputOptions hook. The hook preserves an explicit importAttributesKey value and defaults it to with when unset. Generated external-module imports therefore use the configured import-attribute key.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the fix for preserving the with key on externalized icon JSON imports.
Description check ✅ Passed The description accurately explains the Rollup behavior, runtime failure, implementation, and verification for the changeset.
Linked Issues check ✅ Passed The change configures Rollup to use with while preserving explicit settings, satisfying issue #522.
Out of Scope Changes check ✅ Passed The changes are limited to the Rollup output configuration required to fix externalized icon JSON imports.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@antfu
antfu merged commit 00fa3ab into nuxt:main Aug 10, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

serverBundle.externalizeIconsJson ships assert { type: "json" }, so the icon API 500s on Node 22+

2 participants