-
-
Notifications
You must be signed in to change notification settings - Fork 768
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
Replace node assert with normal error handling #1485
Conversation
Bundle size report: Size Change: +1.47 kB
ℹ️ View DetailsNo major changes |
The only main "issue" I see work this approach is that there is a functionally change in this commit: before this code simply didn't exist in production so if there was an assert that might be triggered but didn't cause any actual error the user wouldn't know as opposed to now where there might be "throws" that cause actual problems. |
All the debug pages seem to just work, so for the most part it is likely a trivial update. But because it technically is more strict, to comply with semver we could make it a 3.0.0-pre.1 and get some feedback. Currently I distinguish if it's a debug build by looking at the filename, checking this |
I would like to keep functionality as much as possible and not create a breaking change version just for this. |
@HarelM , phew, I think that was all of them and the naiveAssert is removed as well. To me it now points more in the direction of a 2.3.1-pre.1 , because it's not intended to be breaking, api-changing or adding any features. |
I am really impressed by the number of comments. You already are at like 50 percent of #209... |
:-) I'll make a final review later on tonight. This will need a pre-release to allow other to test it... |
I've added a few last comment. |
Thanks! These adjustment are in place now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
Cool, thanks for removing these dependencies @birkskyum |
Thank you, but I was merely following @HarelM 's guidance throughout :) Hope this will give us some interesting side benefits. |
Thanks, but it was merely following @HarelM 's guidance throughout (thank!) :) Hope this will give us some interesting side benefit like the option to use an unbundled dev workflow should we want to. |
Needed for maplibre/maplibre-gl-js-docs#230 I think. |
Hint: chrome extension "Refined Github" allow you to hide/unhide resolved comments.
Instead of having the node assert, which are only in the debug build, this PR is either removing the statement if it's unnecessary, or replacing it with throwing a normal error. It would potentially move us quite far towards supporting ecmascript modules.
Instead of having a big 5kb node assert library bundled to the browser with browserify in debug mode, and transpiling everything out of the codebase for prodcution builds, I was thinking about what we needed. Turns out all our assert statements are very simple boolean checks, so we can readily replace them with if statements.
This would mean that it's not server specific code anymore, so browserify is out.
unassert-rollup-plugin
is uncessesary too. These checks now stay in the production code, adding only ~1kB, and they improve our error handling quite a lot.This is obviously adding some lines of code to production, but the benchmarks shown here (left is 2.3, middle is main, right is this branch) says that we don't loose performance because of it.