GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Avoid `require()` call in `@babel/standalone` bundle by nicolo-ribaudo · Pull Request #16639 · babel/babel

Conversation

@nicolo-ribaudo

@nicolo-ribaudo nicolo-ribaudo commented Jul 12, 2024

Copy link
Copy Markdown
Member
Q                       A
Fixed Issues? Fixes #16634
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

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 require calls in ESM files unless they are removed in the IS_STANDALONE bundle.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

declann reacted with hooray emoji
All reactions
  • 🎉 1 reaction
@nicolo-ribaudo
Avoid require() call in @babel/standalone bundle
902047b
@nicolo-ribaudo nicolo-ribaudo added PR: Bug Fix 🐛 A type of pull request used for our changelog categories i: regression pkg: standalone labels Jul 12, 2024
@babel-bot

babel-bot commented Jul 12, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/57354

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

JLHwung
JLHwung approved these changes Jul 12, 2024
View reviewed changes

@JLHwung JLHwung left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@nicolo-ribaudo
Add a test
7e6d33a
@nicolo-ribaudo

nicolo-ribaudo commented Jul 12, 2024

Copy link
Copy Markdown
Member Author

I added a simple test checking the number of require() calls, so that if it changes we notice and can manually review.

JLHwung reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

JLHwung
JLHwung approved these changes Jul 12, 2024
View reviewed changes
@nicolo-ribaudo

nicolo-ribaudo commented Jul 12, 2024

Copy link
Copy Markdown
Member Author

It's getting late here, but I'll merge and release this tomorrow morning :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nicolo-ribaudo
Fix test
0b3e0ff
liuxingbaoyu
liuxingbaoyu reviewed Jul 12, 2024
View reviewed changes
Comment thread packages/babel-standalone/test/built-into-es5.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@liuxingbaoyu

This comment was marked as outdated.

Sign in to view
liuxingbaoyu
liuxingbaoyu approved these changes Jul 13, 2024
View reviewed changes

@liuxingbaoyu liuxingbaoyu left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
nicolo-ribaudo and others added 2 commits July 13, 2024 06:59
@nicolo-ribaudo @liuxingbaoyu
Update packages/babel-standalone/test/built-into-es5.js
2ec220f
Co-authored-by: liuxingbaoyu <[email protected]>
@nicolo-ribaudo
fix test
0caa30b
@nicolo-ribaudo
nicolo-ribaudo merged commit 7d923b8 into babel:main Jul 15, 2024
@nicolo-ribaudo
nicolo-ribaudo deleted the fix-16634 branch July 15, 2024 10:06
@X-oss-byte X-oss-byte mentioned this pull request Aug 5, 2024
[Snyk] Upgrade @babel/core from 7.11.6 to 7.24.9 X-oss-byte/gatsby-1#801
Open
@Exkaleburx Exkaleburx mentioned this pull request Aug 5, 2024
[Snyk] Upgrade @babel/core from 7.9.0 to 7.24.9 Exkaleburx/plug-and-klay#12
Open
@ashly1111111 ashly1111111 mentioned this pull request Aug 5, 2024
[Snyk] Upgrade: , , , , ashly1111111/node#117
Open
This was referenced Aug 5, 2024
[Snyk] Upgrade: , tiff-es/js-looping-and-iteration-looping-code-along-dc-web-091619#206
Open
[Snyk] Upgrade: , tiff-es/fewpjs-class-extensions-super-lab-online-web-sp-000#200
Open
[Snyk] Upgrade: , tiff-es/fewpjs-fns-as-first-class-data-do-behavior-dc-web-091619#195
Open
[Snyk] Upgrade: , tiff-es/fewpjs-adding-behavior-with-methods-dc-web-091619#213
Open
[Snyk] Upgrade: , tiff-es/fewpjs-document-onload-dc-web-091619#202
Open
@davidbilling davidbilling mentioned this pull request Aug 6, 2024
[Snyk] Upgrade @babel/core from 7.24.7 to 7.24.9 davidbilling/ember-cli-time-input#109
Closed
@tiff-es tiff-es mentioned this pull request Aug 6, 2024
[Snyk] Upgrade: , tiff-es/js-data-structures-objects-lab-dc-web-091619#195
Open
@hashim21223445 hashim21223445 mentioned this pull request Aug 6, 2024
[Snyk] Upgrade @babel/core from 7.24.7 to 7.24.9 hashim21223445/async#5
Merged
@tiff-es tiff-es mentioned this pull request Aug 6, 2024
[Snyk] Upgrade: , tiff-es/fewpjs-getter-and-setter-methods-dc-web-091619#215
Open
@Sonic269 Sonic269 mentioned this pull request Oct 4, 2024
[Snyk] Upgrade @babel/core from 7.8.6 to 7.25.2 Sonic269/App6#140
Open
@anandgupta193 anandgupta193 mentioned this pull request Oct 4, 2024
[Snyk] Upgrade @babel/core from 7.10.4 to 7.25.2 anandgupta193/sortNsuffle-react#1138
Open
@DadonStyle DadonStyle mentioned this pull request Oct 4, 2024
[Snyk] Upgrade @babel/core from 7.17.8 to 7.25.2 DadonStyle/Crypto-Tower-FE#28
Open
@blackleadsu blackleadsu mentioned this pull request Oct 4, 2024
[Snyk] Upgrade @babel/core from 7.9.0 to 7.25.2 blackleadsu/PowerBI-visuals-tools#70
Open
@richyhoopd richyhoopd mentioned this pull request Oct 4, 2024
[Snyk] Upgrade @babel/core from 7.9.0 to 7.25.2 richyhoopd/Video-App#1230
Open
@AnushaSalian AnushaSalian mentioned this pull request Oct 4, 2024
[Snyk] Upgrade @babel/core from 7.20.12 to 7.25.2 virtual-labs/ph3-lab-mgmt#547
Open
This was referenced Oct 4, 2024
[Snyk] Upgrade @babel/core from 7.18.2 to 7.25.2 nejidevelops/phase-0-intro-to-js-2-looping-code-along#94
Open
[Snyk] Upgrade @babel/core from 7.18.2 to 7.25.2 nejidevelops/phase-0-javascript-events-acting-on-events-lab#95
Open
[Snyk] Upgrade @babel/core from 7.18.2 to 7.25.2 nejidevelops/phase-0-intro-to-js-2-objects-lab#91
Open
[Snyk] Upgrade @babel/core from 7.4.5 to 7.25.2 nejidevelops/phase-1-domcontentloaded#95
Open
[Snyk] Upgrade @babel/core from 7.4.5 to 7.25.2 nejidevelops/phase-1-destructuring-assignment#93
Open
This was referenced Oct 5, 2024
[Snyk] Upgrade @babel/core from 7.4.5 to 7.25.2 tiff-es/fewpjs-class-extensions-super-lab-online-web-sp-000#242
Open
[Snyk] Upgrade @babel/core from 7.4.5 to 7.25.2 tiff-es/js-data-structures-objects-lab-dc-web-091619#237
Open
[Snyk] Upgrade @babel/core from 7.4.5 to 7.25.2 tiff-es/fewpjs-adding-behavior-with-methods-dc-web-091619#245
Open
[Snyk] Upgrade @babel/core from 7.4.5 to 7.25.2 tiff-es/fewpjs-document-onload-dc-web-091619#247
Open
[Snyk] Upgrade @babel/core from 7.4.5 to 7.25.2 tiff-es/fewpjs-acting-on-events-dc-web-091619#240
Open
[Snyk] Upgrade @babel/core from 7.6.4 to 7.25.2 tiff-es/js-looping-and-iteration-looping-code-along-dc-web-091619#244
Open
@rish2497 rish2497 mentioned this pull request Oct 5, 2024
[Snyk] Upgrade @babel/core from 7.14.3 to 7.25.2 i3-Market-V3-Public-Repository/Support---Deployment-Tools#70
Open
@rawdaymohamed rawdaymohamed mentioned this pull request Oct 5, 2024
[Snyk] Upgrade @babel/core from 7.18.13 to 7.25.2 rawdaymohamed/Hot-Todo#401
Closed
This was referenced Oct 5, 2024
[Snyk] Upgrade @babel/generator from 7.1.3 to 7.25.6 NOUIY/node#490
Open
[Snyk] Upgrade @babel/types from 7.1.3 to 7.25.6 NOUIY/node#491
Open
@richyhoopd richyhoopd mentioned this pull request Oct 6, 2024
[Snyk] Upgrade @babel/core from 7.4.5 to 7.25.2 richyhoopd/RichyFlix#936
Open
@tiff-es tiff-es mentioned this pull request Oct 6, 2024
[Snyk] Upgrade @babel/core from 7.4.5 to 7.25.2 tiff-es/fewpjs-getter-and-setter-methods-dc-web-091619#261
Open
@nejidevelops nejidevelops mentioned this pull request Oct 8, 2024
[Snyk] Upgrade @babel/core from 7.4.5 to 7.25.2 nejidevelops/phase-1-domcontentloaded#97
Open
This was referenced Oct 8, 2024
[Snyk] Upgrade @babel/core from 7.4.5 to 7.25.2 tiff-es/fewpjs-class-extensions-super-lab-online-web-sp-000#244
Open
[Snyk] Upgrade @babel/core from 7.4.5 to 7.25.2 tiff-es/fewpjs-fns-as-first-class-data-array-o-functions-dc-web-091619#246
Open
[Snyk] Upgrade @babel/core from 7.4.5 to 7.25.2 tiff-es/fewpjs-document-onload-dc-web-091619#248
Open
@AnushaSalian AnushaSalian mentioned this pull request Oct 8, 2024
[Snyk] Upgrade @babel/core from 7.20.12 to 7.25.2 virtual-labs/ph3-lab-mgmt#549
Open
@github-actions github-actions Bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 15, 2024
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Oct 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@JLHwung JLHwung JLHwung approved these changes
@liuxingbaoyu liuxingbaoyu liuxingbaoyu approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: standalone PR: Bug Fix 🐛 A type of pull request used for our changelog categories

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[Bug]: errors importing @babel/standalone since yesterdays Babel release

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@nicolo-ribaudo @babel-bot @liuxingbaoyu @JLHwung
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.