Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: prevent island names from shadowing JavaScript globals#3522

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@fry69
Copy link
Contributor

@fry69fry69 commentedOct 5, 2025
edited
Loading

fix#3521

Generated PR message below


Problem

Island files named after JavaScript global objects (e.g., Map.tsx,Set.tsx,Promise.tsx) cause runtime errors. WhenUniqueNamer generates identifiers from these filenames, the resulting variable names shadow global constructors, breaking instantiation:

importMapfrom"/islands/Map.tsx";boot({Map},props);// Map resolves to global constructor, not the island

This results inTypeError: Map is not a constructor when the framework attempts to usenew Map() internally.

Solution

Added JavaScript global objects to theJS_RESERVED set inUniqueNamer. Names matching reserved keywords or globals are now automatically prefixed with underscore:

import_Map_1from"/islands/Map.tsx";boot({_Map_1},props);// No shadowing

Changes

  • utils.ts: ExtendedJS_RESERVED with:

    • JavaScript built-ins (Map, Set, Array, Promise, Object, etc.)
    • Web APIs (fetch, console, URL, WebSocket, etc.)
    • Deno-specific globals (Deno namespace)
    • Node.js compatibility globals (process, Buffer, global)
  • Integration tests: Added test cases for both Builder and Vite build systems verifying islands named after globals work correctly

Impact

Single-location fix inUniqueNamer applies to all code generation (islands, routes, etc.). Island names are prefixed when needed, preserving debuggability while preventing shadowing bugs.

@fry69fry69 changed the titlefix: Prevent island names from shadowing JavaScript globalsfix: prevent island names from shadowing JavaScript globalsOct 5, 2025
Copy link
Collaborator

@marvinhagemeistermarvinhagemeister left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM, thanks!

fry69 reacted with heart emoji
@marvinhagemeistermarvinhagemeister merged commit84576bd intodenoland:mainOct 5, 2025
7 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@marvinhagemeistermarvinhagemeistermarvinhagemeister approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Island files named after global objects cause runtime failures

2 participants

@fry69@marvinhagemeister

[8]ページ先頭

©2009-2025 Movatter.jp