GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Avoid `require()` call in `@babel/standalone` bundle by nicolo-ribaudo · Pull Request #16639 · babel/babel Conversation
Member
I'm not sure about how to test this, since it's about code there just for backwards compat and not actually used. It just being there unused causes problems for bundlers. The solution is that we must not have
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
|
There was an error while loading. Please reload this page.
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/57354 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
If we want to make sure it never happens again, we can use acorn-walk to visit the AST and then throw on require() calls:
babel/packages/babel-standalone/test/built-into-es5.js
Lines 6 to 18 in 3e4723f
| describe("@babel/standalone", () => { | |
| it("should be built into ES5", () => { | |
| const babelStandaloneSource = fs.readFileSync( | |
| require.resolve("../babel.js"), | |
| { encoding: "utf8" }, | |
| ); | |
| expect(() => { | |
| acornParse(babelStandaloneSource, { | |
| ecmaVersion: 5, | |
| sourceType: "script", | |
| }); | |
| }).not.toThrow(); |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I added a simple test checking the number of require() calls, so that if it changes we notice and can manually review. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
It's getting late here, but I'll merge and release this tomorrow morning :) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I see, I can reproduce it only when make use-cjs.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Co-authored-by: liuxingbaoyu <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
[Bug]: errors importing@babel/standalone since yesterdays Babel release
There was an error while loading. Please reload this page.