Skip to content

Vite migration: fix Elm not loading in browser#978

Merged
lucca65 merged 3 commits into
masterfrom
2025-modernization
Apr 27, 2026
Merged

Vite migration: fix Elm not loading in browser#978
lucca65 merged 3 commits into
masterfrom
2025-modernization

Conversation

@lucca65

@lucca65 lucca65 commented Apr 1, 2026

Copy link
Copy Markdown
Member

Summary

  • Upgraded vite-plugin-node-polyfills from v0.7.0 to v0.26.0 — the config used the include/globals API that only exists in v0.22+; the old version ignored these options and injected global shims unconditionally, causing Identifier 'global' has already been declared in deps like @sentry/browser
  • Removed import { TextDecoder, TextEncoder } from "util" — the browser polyfill for util doesn't export these; they are Web API globals available everywhere
  • Removed import fetch from "node-fetch" — this pulled in Node.js http/https internals which Vite externalizes; native fetch is already a browser global

Test plan

  • Run yarn start and confirm no JS errors in the browser console
  • Verify Elm app mounts (loading spinner disappears and the app renders)
  • Confirm EOS transactions still work (eosjs uses TextDecoder/TextEncoder from browser globals now)

🤖 Generated with Claude Code

lucca65 and others added 2 commits December 14, 2025 11:06
Three issues prevented Elm from mounting in the browser:

1. `vite-plugin-node-polyfills` was v0.7.0 but the config used v0.22+ API
   (`include` and `globals` options). The old version ignored those options
   and injected global shims unconditionally, causing `Identifier 'global'
   has already been declared` in deps like @sentry/browser that also declare
   their own `var global`. Fixed by upgrading to v0.26.0.

2. `import { TextDecoder, TextEncoder } from "util"` failed because the
   browser polyfill for `util` doesn't export these — they are Web API
   globals. Removed the import.

3. `import fetch from "node-fetch"` pulled in Node.js `http`/`https`
   internals, which Vite externalizes for browser compatibility. Removed
   the import; native browser `fetch` is already available globally.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@netlify

netlify Bot commented Apr 1, 2026

Copy link
Copy Markdown

Deploy Preview for cambiatus-elm-book failed.

Name Link
🔨 Latest commit a364631
🔍 Latest deploy log https://app.netlify.com/projects/cambiatus-elm-book/deploys/69efdae8e0cf9d000866f6ba

- Stub @sentry/browser in dev to prevent var global/const global conflict
  that prevented Elm from loading after the Vite migration
- Fix config.js to use env-config.js values in development mode (was
  always falling back to hardcoded staging URLs)
- Update README with full local dev instructions including USE_SUBDOMAIN=false
  workflow, subdomain-based dev explanation, and build system notes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@lucca65 lucca65 merged commit 75d0170 into master Apr 27, 2026
2 of 12 checks passed
@lucca65 lucca65 deleted the 2025-modernization branch April 27, 2026 21:54
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.

1 participant