Skip to content

Esm build #1779

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

Merged
merged 21 commits into from
Jan 10, 2019
Merged

Esm build #1779

merged 21 commits into from
Jan 10, 2019

Conversation

cromefire
Copy link
Contributor

For size (#1552) and speed in modern browsers

  • If you've added code that should be tested, please add tests.
  • Ensure your code lints and the test suite passes (yarn lint) & (yarn test).

Signed-off-by: cromefire <[email protected]>
@cromefire
Copy link
Contributor Author

utils are not esm, because there is no single entry point.

The es5 and esm build are side by side in dist and esm.

@cromefire
Copy link
Contributor Author

@kamilogorek Are you okay with me rewriting the imports in the esm modules, so utils can also be esm?

@cromefire cromefire changed the title Added esm build [WIP] Added esm build Dec 3, 2018
@cromefire
Copy link
Contributor Author

There are multiple travis errors that don't seem like I caused them and also travis has problems because this is a PR and so certain env variables are not there.

@cromefire cromefire changed the title [WIP] Added esm build Added esm build Dec 3, 2018
@cromefire cromefire changed the title Added esm build [WIP] Added esm build Dec 3, 2018
@cromefire
Copy link
Contributor Author

I just have to get the rewrite script running under node 6

@cromefire cromefire changed the title [WIP] Added esm build Added esm build Dec 5, 2018
@cromefire cromefire changed the title Added esm build Esm build Dec 5, 2018
@cromefire
Copy link
Contributor Author

This is ready from my site, but there are still some weird travis errors

@HazAT
Copy link
Member

HazAT commented Dec 6, 2018

Thanks for this amazing PR 💯
At first glance this really looks solid, the CI errors are because it's a "third party" PR.

We will test it locally and merge it soon.

utils do not have a single entry point because we wanted to harvest "deep imports" to use different files in browser and node.

Edit: Something that's not necessary but, do you already have some number of how much we size we save using esm over the es5 build?

@cromefire
Copy link
Contributor Author

cromefire commented Dec 6, 2018

We will test it locally and merge it soon.

I still have to turn off side-effects I remembered, so please wait until I did that.

Does any of your files inject something into a global local object, just by importing it?

At first glance this really looks solid, the CI errors are because it's a "third party" PR.

You can turn off certain builds for 3rd party PRs

utils do not have a single entry point because we wanted to harvest "deep imports" to use different files in browser and node.

Yes I fixed it, I always import things like that, it just took some more effort.

Edit: Something that's not necessary but, do you already have some number of how much we size we save using esm over the es5 build?

I can calculate that

@cromefire
Copy link
Contributor Author

If you want I can also do a PR after that to optimize the existing code like introduce es6 classes

@HazAT
Copy link
Member

HazAT commented Dec 6, 2018

Would love that, like I said before the code changes you did so far look really solid :)

@cromefire
Copy link
Contributor Author

Normal:
1300KB

ESM, but splattered (not bundled):
1200KB
min: 220KB
min, gzip (cli defaults): 212KB

Warning: This values are not very good.
Better values when it's released or if I test it via yarn link (maybe tomorrow) and it's not yet optimized for esnext

@cromefire
Copy link
Contributor Author

cromefire commented Dec 9, 2018

My application shows:
default: 22.33KB
esm: 15.48KB
(30.7% less; gzip, min w/ terser)

Copy link
Member

@HazAT HazAT left a comment

Choose a reason for hiding this comment

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

Thank you for your work 🙂👍

@HazAT
Copy link
Member

HazAT commented Dec 13, 2018

Hey, sorry for the delay. We did not forget about this but we still need some time to merge this.
We want to release a patch release first, the next minor bump will include this.

@cromefire
Copy link
Contributor Author

I was thinking about making this more opt in, because right now webpack will automatically choose the module files, which point to esm, what could be a problem for people who already use this with webpack, but don't have babel in place to transpile the files.

Copy link
Contributor

@kamilogorek kamilogorek left a comment

Choose a reason for hiding this comment

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

Sorry for such a long response time, I was over 4 weeks on a vacations.

The code looks nice and should work just fine. However build process is already complex for us and we had some accidents along the way with it.
We need to write some assertions that the build is actually correct and working as well as some assertions around rewrite script before we merge this.

Also packages/raven-js/dist/raven.js has to be restored. It's legacy code and it's used by some people directly through services like rawgit etc. (yup, we had reports like this, so let's just keep it there).

@@ -72,6 +72,17 @@ init({
captureMessage('Hello, world!');
```

If you want sentry to be customized for the browsers you want to support use the `esm` build:
Copy link
Contributor

Choose a reason for hiding this comment

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

This sentence (and the one below) sounds kinda confusing. I'd reword it somehow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure I didn't come up with a better one, but if you have a better idea

@cromefire
Copy link
Contributor Author

Also I thought some time ago, if the esm should be the default module build ("module": "esm/index.js"), because that could break some things for some people using webpack, but not having their code transpiled using babel

@cromefire
Copy link
Contributor Author

All the build errors are coming from either this being a 3rd party PR or from the node module (which I didn't modify)

@cromefire
Copy link
Contributor Author

I think you should skip certain builds in 3rd party PRs so the build does not error. To do that:

@HazAT
Copy link
Member

HazAT commented Jan 10, 2019

@cromefire Thanks for reacting so quickly, could you please just restore the deleted raven-js file and merge master in. All tests should work then.

@HazAT
Copy link
Member

HazAT commented Jan 10, 2019

@cromefire
screenshot 2019-01-10 13 34 35

@cromefire
Copy link
Contributor Author

cromefire commented Jan 10, 2019

Oh my bad obviously there was a problem, I'll look into what went wrong

@cromefire
Copy link
Contributor Author

Yes I'm sorry, as I already said there had to be some problem, while rolling back

@cromefire
Copy link
Contributor Author

cromefire commented Jan 10, 2019

Fixed, it was ignored by the .gitignore (that's also, why it got removed)

@cromefire
Copy link
Contributor Author

Wait, I forgot to put things in .npmignore

@HazAT HazAT merged commit b73d9e9 into getsentry:master Jan 10, 2019
@HazAT
Copy link
Member

HazAT commented Jan 10, 2019

Thanks again, awesome work!

@cromefire cromefire deleted the esm branch January 10, 2019 14:03
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.

3 participants