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

Upgrade Rollup to 0.68.1+ #17352

Closed
MicahZoltu opened this issue Nov 13, 2019 · 10 comments
Closed

Upgrade Rollup to 0.68.1+ #17352

MicahZoltu opened this issue Nov 13, 2019 · 10 comments

Comments

@MicahZoltu
Copy link

MicahZoltu commented Nov 13, 2019

Do you want to request a feature or report a bug?
Bug-ish.

What is the current behavior?
import 'react' (where 'react' is the UMD module build) from an ES module will fail due to rollup/rollup#2274. this is not set in the context of ES modules, so if you try to import 'react' in that context you will get a runtime error since this is undefined and Rollup (before the linked fix) tries to use this when it really means globalThis or self.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your JSFiddle (https://jsfiddle.net/Luktwrdm/) or CodeSandbox (https://codesandbox.io/s/new) example below:

npm install react

index.html

<!DOCTYPE html>
<head><meta charset='utf-8'></head>
<body>
	<script type='module'>
		import './node_modules/react/umd/react.development.js'
	</script>
</body>

What is the expected behavior?
The React UMD module can be loaded by an ES module.

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
React: 16.11.0
Firefox: 70.0.1
Windows 10

@MicahZoltu
Copy link
Author

MicahZoltu commented Nov 13, 2019

This bug is fixed in Babel 7.7.0 Turns out bug is with Rollup (original bug edited), see comment #17352 (comment) for details.

@aweary
Copy link
Contributor

aweary commented Nov 13, 2019

Is there anything actionable for React here? It seems like this was a Babel problem that is now fixed.

@MicahZoltu
Copy link
Author

The action item for React here is to upgrade to the new version of Babel so React can be used in ES modules.

Basically, change the version number on these lines to 7.7.0 or higher and then yarn install (to generate a new yarn.lock file): https://github.com/facebook/react/blob/master/package.json#L7-L34

@bvaughn
Copy link
Contributor

bvaughn commented Jan 9, 2020

Seems like we can remove the "needs info" label. Sounds like the fix is to make sure @babel/plugin-transform-modules-umd (at least) gets updated from the current version (7.2) to one with the bugfix (7.7+).

@bvaughn
Copy link
Contributor

bvaughn commented Jan 9, 2020

@MicahZoltu Any interest in picking this up and submitting a PR? :)

@MicahZoltu
Copy link
Author

@bvaughn PR created, though it has some errors that I don't understand.

@MicahZoltu
Copy link
Author

MicahZoltu commented Jan 10, 2020

Turns out, the issue is actually with an old version of rollup, not babel. Rollup fixed the bug back in December 2018 with rollup/rollup#2594 (though, that contained a bug that was then rectified in rollup/rollup#2600).

I believe the fix for this is included in all versions of Rollup after 0.68.1, so to resolve this issue React needs to upgrade its Rollup version to 0.68.1. I tried to update to 0.68.1 but ran into issues, so I think someone more familiar with the React build process will need to take a look at this.

Note: Rollup is now up to version 1+, it may be worth upgrading all the way to 1 (stable release) if someone is going to take the time to bump the rollup version.

I have updated the original issue title/description with this new information.

@bvaughn
Copy link
Contributor

bvaughn commented Jan 10, 2020

Thanks for the update!

Unfortunately, upgrading certain dependencies (Rollup, Flow) are a little trickier than others. Not sure when we'll get to them, but it is something we discuss from time to time as something we want to get to.

@MicahZoltu MicahZoltu changed the title Upgrade Babel to 7.7.0+ Upgrade Rollup to 0.68.1+ Feb 19, 2020
@alippai
Copy link

alippai commented Jun 30, 2021

This issue is outdated and should be closed. As the current rollup in react is already 1.0+ and the highest available is 2.0+ a new issue would be more appropriate.

@bvaughn
Copy link
Contributor

bvaughn commented Jun 30, 2021

Good call. React is already using Rollup 1.31.1.

@bvaughn bvaughn closed this as completed Jun 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants