-
Notifications
You must be signed in to change notification settings - Fork 24
Build system changes #252
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
Build system changes #252
Conversation
* Switch to type: module * Add esbuild * Don't bundle es5. Only bundle cjs(?) * Explicitly refer to Buffer from the buffer module
cborg doesn't have a default import
instead of "dist/"
Thus we can make them be type: commonjs to not confuse tooling
This reverts commit c5396bb.
Also: * Revert type: module and add type: module package.json to src/ (copied to lib/) * Change configuration files (babel/gen-version) back to cjs, to not confuse tooling * Fix tests that called 'new' on fs.empty * Update keystore-idb to v0.14.2 for browser-friendly builds
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.
There's some issues left to solve.
So, this PR is waiting on those things. |
Node (& some bundlers) require that file imports (not package imports) reference the file with the file extension.
Ignore point (2) above. Not sure why there was an issue, I must have done something wrong. It works flawlessly now. I still need to fix browser tests. Not sure what's going on. :/ Oh and to solve (1), I've changed all our imports. Previously, our imports could only be resolved by typescript, esbuild and rollup (and maybe a couple more). But not e.g. browserify or node.js. This is because they don't support extension-less relative imports. Node doesn't understand |
I've reverted changes from the last comment. I've followed another strategy instead. So, to recap, the issue was: Different environments use different semantics for resolving imports. In According to the stackoverflow post I linked above, most people just use However, unfortunately that won't work with So, I followed the same strategy as this PR. They basically have 100% the same problems as we had. One thing that it doesn't do: It doesn't correctly resolve So much for the explanation. Tests are now running and it's working with various environments: vite, snowpack, esbuild, webpack 5, and - as soon as we'll expose the dependency injection stuff - it'll work in nodejs. |
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.
"start": "ttsc -w", | ||
"test": "jest --forceExit", |
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.
Not totally relevant, but do we want to switch stuff around so yarn test
works "out of the box"? I would suggest make it the same as test:unit
and drop test:unit
... maybe test:prod
should be test:integration
to be more accurate?
Took a look at the latest changes, looks good 👍 Bit of a shame we have to move away from the |
Yes. 😕 I'll keep in mind for the next refactor. |
This PR's changes are mostly centered around the
package.json
file:index.[es5/cjs/umd].js
files and all other modules, e.g.fs/protocol/private/namefilter.js
(I need that for account recovery) would be unchanged from the output fromtsc
. However, we can just remove rollup by:"browser": { crypto: false }
to signal to bundlers to ignorerequire("crypto")
in dependencies (noble-ec25519 has these requires, but is careful not to actually use them in browser contexts)import { Buffer } from 'buffer'
.index.min.js
(previouslyindex.umd.js
) file with something elseesbuild
for creating a convenient browser bundle atdist/index.min.js
. It's fast. Like, <1 second. (Rollup took >20 secs for just the index.umd.js)lib/
. We keepdist/index.min.js
, though. I think this distinction is nice.import "webnative/fs/protocol/private/namefilter"
is now possible instead ofimport "webnative/dist/fs/protocol/private/namefilter"
.tsc
. We require node version >=15, which supports newer features like that anyway.Seems like a lot, but it's not actually that many changes in terms of lines. Most of the changes are ~700 removed lines from getting rid of rollup dependencies.
To do
(Apart from getting a review of this)
Test that this works with different bundlers:
Let me know if I should add something to this list.