-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: change platform for CJS bundle from node to browser (#2454)
That should fix the problem with node-specific versions of packages included in the CJS bundle.
- Loading branch information
1 parent
41013af
commit 4bc2d35
Showing
4 changed files
with
169 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,19 @@ | ||
// As the community transitions to ESM, we can easily break our CJS bundle. | ||
// This smoke test can help to detect this early. | ||
|
||
// First, set up minimal browser-like environment: | ||
const { JSDOM } = require('jsdom'); | ||
const dom = new JSDOM('', { | ||
url: 'https://localhost', | ||
}); | ||
|
||
global.window = dom.window; | ||
|
||
for (const key of Object.keys(window)) { | ||
if (global[key] === undefined) { | ||
global[key] = window[key]; | ||
} | ||
} | ||
|
||
// Then, try importing our CJS bundle: | ||
require('../dist/index.cjs.js'); |
This file contains 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