rrweb icon indicating copy to clipboard operation
rrweb copied to clipboard

[Feature Request]: Publish ESM on CDN

Open otakustay opened this issue 3 years ago • 6 comments

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

otakustay avatar Sep 15 '22 02:09 otakustay

Is this jsDelivr link your wanted feature? https://www.jsdelivr.com/package/npm/rrweb?path=es%2Frrweb%2Fpackages%2Frrweb%2Fsrc%2Frecord

YunFeng0817 avatar Sep 15 '22 03:09 YunFeng0817

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

otakustay avatar Sep 15 '22 04:09 otakustay

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

YunFeng0817 avatar Sep 15 '22 04:09 YunFeng0817

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?

otakustay avatar Sep 15 '22 04:09 otakustay

I think it's possible but we don't have enough time to create a separate config for this situation.

YunFeng0817 avatar Sep 15 '22 04:09 YunFeng0817

I'm going to try to create a PR for this

otakustay avatar Sep 15 '22 05:09 otakustay

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

Juice10 avatar Nov 02 '22 19:11 Juice10