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

Switch the build process to rollup.js #130

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

realityking
Copy link
Contributor

@realityking realityking commented Oct 21, 2017

Makes the minified UMD build 1.2kb smaller. Rollup also eliminates a lot of closures, I suspect the code would be a tiny bit faster.

@facebook-github-bot
Copy link

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@realityking
Copy link
Contributor Author

@aweary Could you have a look at this one?

@realityking
Copy link
Contributor Author

@aweary ping

@gaearon
Copy link
Contributor

gaearon commented Jun 19, 2018

Can you please rebase and I'll take a look?

@realityking
Copy link
Contributor Author

@gaearon Rebased! And thanks for taking care of fbjs in prop-types as well :)

@gaearon
Copy link
Contributor

gaearon commented Jun 19, 2018

While we're at it, could you also add Babel plugin for good measure?

@realityking
Copy link
Contributor Author

Done. Though I don't think it actually transforms anything 🤔

package.json Outdated
@@ -26,25 +26,24 @@
"homepage": "https://facebook.github.io/react/",
"dependencies": {
"loose-envify": "^1.3.1",
"object-assign": "^4.1.1"
"object-assign": "^4.1.1",
"rollup-plugin-babel": "^3.0.4"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this please to devDependencies

rollup.config.js Outdated

export default [
createConfig('prop-types.js'),
createConfig('prop-types.min.js', {uglify: true, production: true})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of configurable config factory it's cleaner to just write two configs and reuse input and output.name like here.

rollup.config.js Show resolved Hide resolved
@realityking
Copy link
Contributor Author

@TrySound Made the changes you suggested. Not sure if I like the new structure of the rollup config so I made that change in a different commit.

rollup.config.js Outdated
babel({
exclude: 'node_modules/**'
}),
replace(stripEnvVariables(options.production)),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

false

rollup.config.js Outdated
babel({
exclude: 'node_modules/**'
}),
replace(stripEnvVariables(options.production)),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true

@realityking
Copy link
Contributor Author

Ups, fixed. (And more a bit easier to follow.

@TrySound
Copy link

@gaearon I think the PR is ready to merge.

@TrySound
Copy link

Hey @gaearon. Any thoughts on this?

@TrySound
Copy link

Hi @gaearon! Do you have a time to take a look at this?

@ljharb
Copy link
Collaborator

ljharb commented Feb 8, 2019

Due to bugs like rollup/rollup#2540, I don't think rollup is safe to use on any project at this time. Thanks for the PR!

@ljharb ljharb closed this Feb 8, 2019
@gaearon
Copy link
Contributor

gaearon commented Feb 8, 2019

To be fair, we do use Rollup for React itself. Since prop-types doesn't do any feature detection I wouldn't worry about it.

Ideally our build process should run tests on compiled bundles. That would be sufficient to feel good about it IMO since the surface area is very narrow.

@realityking
Copy link
Contributor Author

realityking commented Feb 8, 2019

I‘m sorry, I‘m confused. As @Gaeron pointed out, rollup is widely used for React and related libraries. Why wouldn‘t it be a good a fit for prop-types?

Rollup is not for every library and I wouldn‘t use it to bundle an application but it poses a clear win (size) for this lib.

@ljharb
Copy link
Collaborator

ljharb commented Feb 8, 2019

@gaearon fair enough! reopening.

@ljharb ljharb reopened this Feb 8, 2019
@TrySound
Copy link

TrySound commented Feb 8, 2019

@gaearon Would be good to finally merge it.

@gaearon
Copy link
Contributor

gaearon commented Feb 8, 2019

@ljharb volunteered to help clean up the repo so I trust him to make these decisions.

Makes the minified UMD build 1.2kb smaller
@realityking
Copy link
Contributor Author

I went through my open PR and found this gem from almost 3 (!) years ago. I've rebased it and upgraded all added dependencies to be the same version as in the react repository. I'd still love to see it merged. What do y'all think?

As an aside, going to the newest version of the rollup dependencies would require upgrading babel to version 7. Happy to do that if there's interest in that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants