Skip to content

fix: js.exports.createNamed fails if the AST contains a function declaration#1084

Merged
jycouet merged 1 commit intomainfrom
js-exports-createnamed-fails-if-the-ast-contains-a
May 7, 2026
Merged

fix: js.exports.createNamed fails if the AST contains a function declaration#1084
jycouet merged 1 commit intomainfrom
js-exports-createnamed-fails-if-the-ast-contains-a

Conversation

@jycouet
Copy link
Copy Markdown
Contributor

@jycouet jycouet commented May 7, 2026

Closes #1083

Description

js.exports.createNamed crashed with TypeError: Cannot read properties of undefined (reading '0') when the AST contained an exported function (or class) declaration. The lookup blindly cast the export's declaration to VariableDeclaration. Now it branches on declaration type and reads id.name for function/class declarations.

Checklist

  • Update snapshots (if applicable)
  • Add a changeset (if applicable)
  • Allow maintainers to edit this PR
  • I care about what I'm doing, no matter the tool I use (Notepad, Sublime, VSCode, AI...)

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 7, 2026

🦋 Changeset detected

Latest commit: ebe1350

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@sveltejs/sv-utils Patch
sv Patch

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

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 7, 2026

Open in StackBlitz

npx https://pkg.pr.new/svelte-migrate@1084
npx https://pkg.pr.new/sv@1084
npx https://pkg.pr.new/@sveltejs/sv-utils@1084

commit: ebe1350

@svelte-docs-bot
Copy link
Copy Markdown

@jycouet jycouet merged commit a991697 into main May 7, 2026
8 checks passed
@jycouet jycouet deleted the js-exports-createnamed-fails-if-the-ast-contains-a branch May 7, 2026 20:15
@github-actions github-actions Bot mentioned this pull request May 7, 2026
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.

js.exports.createNamed fails if the AST contains an exported function declaration (sv-utils)

1 participant