rrweb
rrweb copied to clipboard
[Feature Request]: Publish ESM on CDN
Preflight Checklist
- [X] I have searched the issue tracker for a feature request that matches the one I want to file, without success.
What package is this feature request for?
rrweb
Problem Description
For pages that asynchronously install rrweb recorder, we currently use createElement('script') and script.onload to lazy import rrweb-record.min.js, but it will be more confortable if we can simply use await import('rrweb-record.esm.js').
Proposed Solution
Build and publish bundled ESM modules alongside current dist
Alternatives Considered
Using createElement('script') works but is a little complicated
Additional Information
No response
Is this jsDelivr link your wanted feature? https://www.jsdelivr.com/package/npm/rrweb?path=es%2Frrweb%2Fpackages%2Frrweb%2Fsrc%2Frecord
Since these es files seems to be generated directly from ts files, I'm not sure if they will include some new language features that not work on older (but still supports ESM) browsers, maybe a bundled version can be better
They are actually bundled with rollup. You can see the bundling configuration here: https://github.com/rrweb-io/rrweb/blob/master/packages/rrweb/rollup.config.js
I still see some import statements in src/record/index.js, would it be possible that the ES version is exactly like the single file dist version, elliminating multiple network requests?
I think it's possible but we don't have enough time to create a separate config for this situation.
I'm going to try to create a PR for this
I believe this PR might fix it: https://github.com/rrweb-io/rrweb/pull/1033 It's not finished yet but includes esm in release