Rewrite prism in esm
See original GitHub issueMotivation Many modules are supporting esm now, it is better for bundlers to do tree-shaking and do care node.js and browser environment with separated bundle.js.
Description
Bundlers like rollup or webpack want to see esm modules and they do tree-shaking for smaller size. Currently you’re using cjs and supporting both node.js and browser by hand (instead of umd). This is bad bacause it exports some global variables like _self
in browser and you won’t be able to use it in the native esm way because import
s order is not guaranteed. See vite#1438 since vite depends on native esm in development mode. This solution is also wrong.
As a result, your package.json should look like this:
{
// node's require and import, to override it, see "exports"
"main": "dist/index.js",
// https://nodejs.org/api/packages.html#packages_conditional_exports
"exports": {
"node": {
"import": "./src/index.mjs",
"require": "./dist/index.js"
},
"default": "./src/index.browser.mjs"
},
// front-end bundler read this (like vite or webpack)
"module": "src/index.browser.mjs"
}
Issue Analytics
- State:
- Created 3 years ago
- Reactions:18
- Comments:13 (4 by maintainers)
Top Results From Across the Web
Developers - Rewrite prism in esm - - Bountysource
Coming soon: A brand new website interface for an even better experience!
Read more >rehype-prism | Yarn - Package Manager
The unified plugin used to highlight code block in html with Prism. Usage.
Read more >Chapter 2 - The PRISM framework
The PRISM system specifications were produced by the PRISM System ... rewrite of the Met Office very complete suite of tools for ESMs...
Read more >The case for Weak Dependencies in JS - Lea Verou
One issue with ESM (and other module systems) is that you can't have optional dependencies. With globals, you could check if a global...
Read more >August 2015 – svenweller - WordPress.com
MYSCHEMA, MV_CLI_PROGRAMME_USER, REWRITE_FULL_TEXT_MATCH, F, ESM.PERSON, 216, 2099, mv references a remote table or view in the FROM list ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It’s planned for v2, so yes.
Implemented in v2.