Vite migration: fix Elm not loading in browser#978
Merged
Conversation
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>
❌ Deploy Preview for cambiatus-elm-book failed.
|
- 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
vite-plugin-node-polyfillsfrom v0.7.0 to v0.26.0 — the config used theinclude/globalsAPI that only exists in v0.22+; the old version ignored these options and injected global shims unconditionally, causingIdentifier 'global' has already been declaredin deps like@sentry/browserimport { TextDecoder, TextEncoder } from "util"— the browser polyfill forutildoesn't export these; they are Web API globals available everywhereimport fetch from "node-fetch"— this pulled in Node.jshttp/httpsinternals which Vite externalizes; nativefetchis already a browser globalTest plan
yarn startand confirm no JS errors in the browser console🤖 Generated with Claude Code