Standard compliant ES Modules format
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 31.7k
- Forks
- 3k
- PR merge metrics
- No merged PRs in 30d
Description
Feature Request
RxJS should come in a standard compliant (browser-friendly) ES Modules format.
Describe the solution you'd like
The _esm5 and _esm2015 are close to what we need, but still far from standards. First of all, ES Modules means the browser definitely supports ES6, so no need for esm5 output to be honest.
Next, the _esm2015 format still misses .js file extensions and without them it is impossible for the browser to know what are we trying to load (it works literally as with script src or css link, it needs to point to the exact file, browser will not check for multiple locations as each check has a network latency cost). Furthermore, the _esm2015/internal/Rx.js file has bunch of imports (rxjs-compat) based on Bare Module Specifier (which is strictly a node.js resolution system, not existing in the browser).
In order for the format to be standard compliant, it needs to point to exact file on the server.
Describe alternatives you've considered
So far the only 2 ways of dealing with the issue is to have the server that rewrites the path or bundle the output. As bundling is often a must on production anyway, it is not needed on many development workflows, as it would only slow down the browser reactivity to changes. Path rewrites on-the-fly however work only for custom servers. Some projects use existing tools and writing custom logic just makes more code to maintain, not to mention possible bugs slowing down the development. It would be great to just fetch the file from cdn and not care about further post processing.
This issue has been raised already in #2858 and #3858 but so far both issues are closed and locked as resolved (which is not how it is). Back then browser support for ES Modules could have been lower, but at this moment we have all of the major browsers having a stable implementation enabled by default which gives over 80% of the browsers supporting the feature (node.js also supports it now behind the flag). I really think supporting this format should be a high priority for rxjs.
P.S. Adding module field to package.json would also be a nice addition to the above.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by inspecting the generated _esm5 and _esm2015 outputs, especially _esm2015/internal/Rx.js, and the package.json metadata. Define the browser-compatible output requirements around explicit .js extensions, removal of bare rxjs-compat specifiers, and the optional module field; done means the published format can be loaded directly by browsers without path rewriting or bundling.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100