Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

standalone does not work in ES5 #7607

Closed
arv opened this issue Mar 21, 2018 · 16 comments
Closed

standalone does not work in ES5 #7607

arv opened this issue Mar 21, 2018 · 16 comments
Labels
i: bug outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: standalone

Comments

@arv
Copy link
Contributor

arv commented Mar 21, 2018

I'm trying to run @babel/standalone in an ES5 environment. I'm not sure this is target platform or not?

Anyway, one way to try this out is to use a really old version of node (0.10 for example)

Input Code

yarn add @babel/standalone
nvm install 0.10
nvm use 0.10
node node_modules/@babel/standalone/babel.js

Expected Behavior

I was hoping this would work. It works on the 6.x branch

Current Behavior

$ node node_modules/\@babel/standalone/babel.js

/src/test-babel/node_modules/@babel/standalone/babel.js:6578
var BLOCK_SCOPED_SYMBOL = Symbol.for("var used to be block scoped");
                          ^
ReferenceError: Symbol is not defined
    at Object.<anonymous> (/src/test-babel/node_modules/@babel/standalone/babel.js:6578:27)
    at __webpack_require__ (/src/test-babel/node_modules/@babel/standalone/babel.js:30:30)
    at Object.<anonymous> (/src/test-babel/node_modules/@babel/standalone/babel.js:9308:18)
    at __webpack_require__ (/src/test-babel/node_modules/@babel/standalone/babel.js:30:30)
    at Object.<anonymous> (/src/test-babel/node_modules/@babel/standalone/babel.js:5258:1)
    at __webpack_require__ (/src/test-babel/node_modules/@babel/standalone/babel.js:30:30)
    at Object.exports.__esModule (/src/test-babel/node_modules/@babel/standalone/babel.js:9266:20)
    at __webpack_require__ (/src/test-babel/node_modules/@babel/standalone/babel.js:30:30)
    at Object.<anonymous> (/src/test-babel/node_modules/@babel/standalone/babel.js:8151:38)
    at __webpack_require__ (/src/test-babel/node_modules/@babel/standalone/babel.js:30:30)

Possible Solution

Are we not including the ES6 polyfills?

Context

Trying to run @babel/standalone in an ES5 engine (nashorn)

@babel-bot
Copy link
Collaborator

Hey @arv! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community that typically always has someone willing to help. You can sign-up here
for an invite.

@jpsc
Copy link

jpsc commented Mar 26, 2018

Node 4.0 is a month of being discontinued so I think that babel will strive to be at least only 6 if not 8.
The CI is running 9 btw.

@loganfsmyth
Copy link
Member

@jpsc Babel 7 will likely target Node 6, but this issue is specifically around babel/standalone, which is targeted more at users with ES5 environments since it is often run in browsers.

@jpsc
Copy link

jpsc commented Mar 26, 2018

Oh okay. Gotcha. 0.10 was just used as an example.

@hzoo
Copy link
Member

hzoo commented Mar 26, 2018

Yeah that's true, we do want to target ES5 for standalone. I think it's different though, I guess we weren't using polyfillable things like Symbol before? But yeah I don't think standalone would include the polyfill for you unless we have a good way of doing so

@loganfsmyth
Copy link
Member

It seems like standalone should bundle babel-runtime? That was honestly my assumption until this was filed.

@hzoo
Copy link
Member

hzoo commented Mar 26, 2018

Oh yeah, hmm @danez @Daniel15 forgot what happened

@Daniel15
Copy link
Member

babel-standalone should support ES5, we should load any polyfills/runtimes that are required to do so.

@danez
Copy link
Member

danez commented Mar 27, 2018

But that means babel is not producing es5 code anymore but using some newer stuff?

@hzoo hzoo added the i: bug label Mar 31, 2018
@hzoo
Copy link
Member

hzoo commented Mar 31, 2018

Oh ^ the babel-runtime thing makes sense.

I think it's that babel itself used to be compiled with transform-runtime which would include things like Symbol. But we dropped that since we dropped Node 0.10/0.12. In the case of older browsers we would want to add it back in. Although, I think we could probably do another bundle that doesn't need that too for modern browsers like everyone else is doing.

@arv
Copy link
Contributor Author

arv commented Mar 31, 2018

Manually loading the polyfills first works. I just wasn't sure what the intent was/is?

@loganfsmyth
Copy link
Member

I don't have a problem with babel-standalone including everything needed to compile in ES5.

Although, I think we could probably do another bundle that doesn't need that too for modern browsers like everyone else is doing.

Is there any demand for that? It's only really the REPL usecase and the non-Node usecases where we recommend standalone, so it seems fine to aim for ES5 for it.

@loganfsmyth
Copy link
Member

Posted a PR for this FYI: #8024

@nicolo-ribaudo
Copy link
Member

Fixed by #8024

@TrevorBurnham
Copy link

I'm trying to get @babel/standalone@7 running in IE11 and getting the error:

WeakSet is undefined

Polyfilling WeakSet is simple enough, but when I do so I get a different error:

Object.keys argument is not an object

Can you tell me what I need to do to get the new version of babel-standalone running in an ES5 environment? I had no trouble with babel-standalone@6.

@ktor
Copy link

ktor commented Jan 22, 2020

I'm trying to run 7.8.3 version in Java Nashorn (jdk1.8) and it fails with the same error. Version 6.26.0 works (https://registry.npmjs.org/babel-standalone/-/babel-standalone-6.26.0.tgz).

@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 Apr 23, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: bug outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: standalone
Projects
None yet
Development

No branches or pull requests

10 participants