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

In-browser JSX translation broken with 7.9 -> 7.10 upgrade. #11621

Closed
daniel-s opened this issue May 27, 2020 · 9 comments · Fixed by #11624
Closed

In-browser JSX translation broken with 7.9 -> 7.10 upgrade. #11621

daniel-s opened this issue May 27, 2020 · 9 comments · Fixed by #11624
Labels
i: bug i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@daniel-s
Copy link

daniel-s commented May 27, 2020

edit by @hzoo:

Workaround can be (until 7.10.1 patch is out)

- <script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
+ <script src="https://unpkg.com/@babel/standalone@7.9.0/babel.min.js"></script>

Bug Report

Current behavior

In browser JSX translation does not work for Babel 7.10.0.

A script tag in HTML like the following works fine.

<script src="normal_script.js"></script>

A tag like this does not work:

<script src="react_script.jsr" type="text/babel"></script>

By does not work I mean that no Javascript in that file will execute. Not even simple JS that does not require any translation. For example, if react_script.jsr contained only this line:

console.log("hi world");

it would fail to execute.

This issue is remedied back to normal if following change is made to the HTML.

<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>

changed to

<script src="https://unpkg.com/@babel/standalone@7.9.0/babel.min.js"></script>

Expected behavior

The above not to break as described.

Environment

- Babel version(s): v7.10.0
- OS: Windows 10 and Linux 4.19
- Browser: Chrome and Firefox

**Possible Solution**
Temp workaround: use v7.9.0 of babel.
@babel-bot
Copy link
Collaborator

Hey @daniel-s! 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."

@epihel
Copy link

epihel commented May 27, 2020

This might be related to this CI failure: https://github.com/babel/babel/runs/710737539. It looks like other babel modules for version 7.10.0 successfully published, but if any version of @babel/plugin-proposal-class-properties is included in package.json, then npm install fails.

@hzoo
Copy link
Member

hzoo commented May 27, 2020

Must be related to #11466, if you look at the history of standalone? https://github.com/babel/babel/commits/master/packages/babel-standalone

cc @dfabulich if have any ideas!

@hzoo
Copy link
Member

hzoo commented May 27, 2020

Ok looks like type: script.getAttribute("data-type"), should be type: script.getAttribute("data-type") || "", or the if check should be changed to include null in https://github.com/babel/babel/pull/11466/files#diff-7a71ff75920619cbc0e67883df263ca8L53.

I guess in this case, the workaround for 7.10 babel/standalone would be to define a data-type in your script tag (other than using 7.9).

@arku
Copy link
Contributor

arku commented May 27, 2020

@hzoo I would like to fix this issue.

@dfabulich
Copy link
Contributor

The fix is ready! Sorry everybody!

@arku
Copy link
Contributor

arku commented May 27, 2020

@dfabulich Ah, you beat me to it.

Let me close my PR. Thanks for the quick fix!

@thecodejack
Copy link

Hey guys...our builds are breaking. Any ETA on release?

@nicolo-ribaudo
Copy link
Member

Later today

dfabulich added a commit to dfabulich/babel that referenced this issue May 27, 2020
@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 Aug 27, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: bug i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
9 participants