-
Notifications
You must be signed in to change notification settings - Fork 2
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
Make library tree-shakable #44
Conversation
1b903fd
to
4c5bdcc
Compare
TODO remove once ably-forks/vcdiff-decoder#44 merged
TODO remove once ably-forks/vcdiff-decoder#44 merged
TODO remove once ably-forks/vcdiff-decoder#44 merged
TODO remove once ably-forks/vcdiff-decoder#44 merged
TODO remove once ably-forks/vcdiff-decoder#44 merged
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.
Changes all looks reasonable to me but would you mind setting up a workflow to run npm test
, feels quite important to be able to see the tests passing alongside this kind of refactoring
TODO remove once ably-forks/vcdiff-decoder#44 merged
We expose an ES module version of the library for module bundlers to use, and generate a CommonJS version for Node. The motivation is that, for [1] I want to re-export this library from ably-js as a tree-shakable module. Tree-shakability requires that we use ES modules. I’ve output the Node bundle to a new `build` directory, since I don’t know whether the `dist` directory has some special meaning for the `ably-env deploy` script and so didn’t want to put non-CDN stuff in there. The version of Node that the README tells us to use does not support ES modules, so we generate a CommonJS bundle for the tests to use, which includes all of the internal components so that they can be tested. I tested these changes for regressions by: 1. running `npm run grunt -- test:node` 2. running `npm run grunt -- test:browser:local` 3. generating an NPM package using `npm pack`, installing it in ably-js, and running the delta tests there [1] ably/ably-js#1492
Motivation as in 9d8aeb8, and tested in the same way. I don’t know exactly _what_ about the non-class way of doing things made it not be tree-shakable; I can only speculate that it was the `.prototype.foo = ...` statements. The update to Babel is because the version we were using didn’t support class fields.
Motivation as in 9d8aeb8.
Not running the BrowserStack ones because I don’t want to spend time getting credentials set up right now. I’ve changed the browser to headless to avoid the error "no DISPLAY environment variable specified" in CI.
4c5bdcc
to
f733809
Compare
Sure, I've pushed a commit to run the Node tests and local browser tests (runs in Firefox). I haven't configured it to run the BrowserStack tests — would you like me to? If so, do you know whether we already have some credentials I could get my hands on? |
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.
I think these tests are sufficient for now, we haven't used browserstack in a while and i'd lean towards using playwright if we want to expand the browser testing in future
For ably/ably-js#1492 I want to re-export this library from ably-js as a tree-shakable module. In order to make the library tree-shakable, I convert it to use ES modules and ES classes, and mark one expression as
/* @__PURE__ */
. See commit messages for more details.