noVNC as real ESM, one module shape for every bundler - #271
Merged
Conversation
@novnc/novnc 1.5.0 ships only Babel CommonJS, and the bundlers disagree about what its default import means: dev and vitest unwrap exports.default to the class, while the production build follows Node semantics and hands back the whole exports object — so the deployed login window died at new RFB() with 'zi.default is not a constructor'. 1.7.0 is type: module with an exports map pointing the bare specifier at core/rfb.js. Real ESM, no interop anywhere: the bare import resolves the class identically in dev, vitest, and the build.
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.
@novnc/novnc1.5.0 ships only Babel CommonJS, and the bundlers disagree about what its default import means: dev and vitest unwrapexports.defaultto the class, while the production build (rolldown) follows Node's CJS-interop semantics and hands back the whole exports object. The login window page therefore worked everywhere except the deployed bundle, wherenew RFB(...)compiled tonew zi.default(...)withzi.defaultbeing the exports object — the live error:zi.default is not a constructor.1.7.0 is
type: modulewith an exports map pointing the bare specifier atcore/rfb.js. Real ESM ends the interop question: the bareimport RFB from '@novnc/novnc'resolves the class identically in dev, vitest, and the build. The page's use of RFB (constructor,scaleViewport,resizeSession, connect/disconnect events) is unchanged across 1.5→1.7.Verified in the built bundle: the construction site is now a direct
new <class>(...)with no.defaultindirection, and the class resolves to RFB's real constructor. 117 frontend tests pass; lint and tsc clean.Deploy: the fix rides the next druks image build — redeploy after merge.