Skip to content
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

Distribute ES Modules (ESM) so we can benefit from tree shaking #18

Open
OliverJAsh opened this issue Nov 3, 2021 · 1 comment
Open

Comments

@OliverJAsh
Copy link

Hi, this library looks really useful and we would like to use it at Unsplash!

However it seems that the npm module only provides CommonJS modules. Would it be possible to distribute ES Modules as well, so we can benefit from tree shaking which will help to reduce our bundle size?

@kosich
Copy link
Contributor

kosich commented Nov 9, 2021

Hey, Oliver! That's a very important feature of a library indeed.

As an option, currently one can directly import a submodule from the package subfolder, e.g.:

import {fromResizeObserver} from 'rxjs-web/lib/observer/resizeObserver.js';

fromResizeObserver(window.document.body)
  .subscribe(console.log);

while, I think, this is not a proper solution and relies on intricacies of the folder structure, which potentially can change.

.

P.S: I don't know how to config ESM build output using Nx (current build tool), but if someone wants to champion this, I have a tsc based build system that targets multiple output module types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants