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 progress] Modernize Build tooling, optimize code size #65

Merged
merged 13 commits into from
Sep 11, 2018
Merged

[In progress] Modernize Build tooling, optimize code size #65

merged 13 commits into from
Sep 11, 2018

Conversation

onigoetz
Copy link
Contributor

@onigoetz onigoetz commented Jul 27, 2018

Hello,
as discussed in the Globalize repository, this pull request will make a version that is optimizable by build tools like webpack.

But there is a lot of work required to get there due to the tools used currently
I open this pull request early so that you can see the progress and give your feedback if you're ok with the direction it's taking

  • Convert Code to use require() from nodejs
  • Remove Bower, do everything through npm
  • Use rollup or webpack to build bundles
  • Convert Code to ES 6 imports, gives better results when optimizing with Webpack
  • Change output so we don't need to add ".default" on import without babel
  • Use babel in compilation to wrap validate*( with conditions to remove them in production builds
  • Provide a "source" build for webpack
  • Use eslint + prettier instead of jshint

Remove bower

Signed-off-by: Stéphane Goetz <onigoetz@onigoetz.ch>
@onigoetz
Copy link
Contributor Author

Hi @rxaviers,

I finished the initial implementation of the changes.

You can start reviewing if you feel like it. I still need to add a few benchmarks on what you can expect for the final size with all the "validate" calls removed in production and do some tests to make sure that everything works as it did before.

I recommend you look at the commits separately, I tried to make them in the right order and well separated, otherwise, looking at all the changes at once might give you a headache :)

I also recommend checking the box "Hide whitespace changes" to have less false positives of line changes.

@rxaviers
Copy link
Owner

rxaviers commented Aug 13, 2018

Awesome! Thank you for your contribution. One highlevel comment for now: Mocha doesn't need a browser to run either. Can we do the analogous test changes you did but keeping mocha? Thanks

@onigoetz
Copy link
Contributor Author

Oh, I was sure of the contrary. my mistake :)

I will revert that part then. I have to admit I'm more familiar with Jest, but I'll figure it out :)

@rxaviers
Copy link
Owner

Also feel free to get rid of grunt and instead use npm scripts directly.

@rxaviers
Copy link
Owner

@onigoetz
Copy link
Contributor Author

Good to know for Grunt, but there is no cli for grunt-dco / dco . Do you want to keep that plugin ?

Thanks for the links for Mocha

@rxaviers
Copy link
Owner

Good point! We can leave only that in grunt for now until a CLI is made available for it, which shouldn't be hard to create (that hypothetical module could use https://github.com/scottgonzalez/dco)

@onigoetz
Copy link
Contributor Author

sure, I already checked how hard it would be to create that, but I wanted to make sure that you still want it first :)

@rxaviers
Copy link
Owner

Thanks for checking!

@onigoetz
Copy link
Contributor Author

Oh and I wanted to ask, do you wish to keep jshint or to use eslint ?

@rxaviers
Copy link
Owner

Let's go with eslint + prettier (we could use https://github.com/rxaviers/async-pool/blob/master/package.json settings as baseline for that too)

@onigoetz
Copy link
Contributor Author

aaand, mocha and eslint it is :)

Signed-off-by: Stéphane Goetz <onigoetz@onigoetz.ch>
…the same

Signed-off-by: Stéphane Goetz <onigoetz@onigoetz.ch>
Signed-off-by: Stéphane Goetz <onigoetz@onigoetz.ch>
Signed-off-by: Stéphane Goetz <onigoetz@onigoetz.ch>
…apped in if (process.env.NODE_ENV !== "production")

Signed-off-by: Stéphane Goetz <onigoetz@onigoetz.ch>
Signed-off-by: Stéphane Goetz <onigoetz@onigoetz.ch>
Signed-off-by: Stéphane Goetz <onigoetz@onigoetz.ch>
Signed-off-by: Stéphane Goetz <onigoetz@onigoetz.ch>
Signed-off-by: Stéphane Goetz <onigoetz@onigoetz.ch>
Signed-off-by: Stéphane Goetz <onigoetz@onigoetz.ch>
Signed-off-by: Stéphane Goetz <onigoetz@onigoetz.ch>
@onigoetz
Copy link
Contributor Author

I also made a small script to replace grunt-dco and removed grunt

@onigoetz
Copy link
Contributor Author

"yarn build" or "npm run build" builds everything now

@onigoetz
Copy link
Contributor Author

I made some tests on the size of the library

File 0.5.0 (min) Current, build Current, through webpack
cldr.js 4586 B 5659 B ( +1073 ) 1055 B ( -3531 )
cldr/event.js 3881 B 5435 B ( +1554 ) 6682 B ( +2801 )
cldr/supplemental.js 1175 B 2325 B ( +1150 ) 3865 B ( +2690 )
cldr/unresolved.js 1141 B 2737 B ( +1596 ) 3931 B ( +2790 )
All 10783 B 16156 B ( +5373 ) 9525 B ( -1258 )

It seems the UMD build is bigger, but the global size of the build with webpack is smaller.

@rxaviers rxaviers merged commit 3139aa7 into rxaviers:master Sep 11, 2018
@rxaviers
Copy link
Owner

rxaviers commented Sep 11, 2018

What you have done here is already a big improvement and therefore I am merging it. I still want to do additional things with respect to the build and modules. Will post details in an upcoming PR.

@rxaviers
Copy link
Owner

Follow up #66

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

Successfully merging this pull request may close these issues.

2 participants