Open brettz9 opened 3 years ago
Sure, but only native ESM. I don't want any build step. You need to target Node.js 12.
You can see how I recently did it here: https://github.com/sindresorhus/quick-lru/commit/a408ce9b3ad430607f1f3e3077d1d21636343015
Thanks. I don't see a clear way for Karma to be used with ESM outside of an old Karma ESM package which is recommending Web Test Runner. Should I switch to that test runner?
Sure
Hmmm...
In order to preserve the detection and dynamic registration of your "shortcut" capabilities, I think the API would need to change to support the asynchronous nature of the dynamic native ESM imports, i.e., one would have to import an export function and await its result in order to use the Observable.
Top-level await might be usable, but would require Node 14+ (and browser support is currently very limited: https://caniuse.com/mdn-javascript_operators_await_top_level ).
Alternatively, the dynamic detection could be dropped in favor of requiring a specific implementation.
What problems does making this package ESM solve? Because it sounds like converting it to ESM will cause more problems than it solves. ESM can import CommonJS.
I like being able to make direct imports without a build step for browser (or polyglot) environments, but maybe it is just best to wait (or I could just make a specific fork). Will close for now then. Thanks!
I'd like to keep this open so it's not forgotten. There's some useful info here. I'll circle back to this issue later this year.
Open to an ESM PR, for native ESM and/or Rollup?