Should Prism-core be default exported?
Open
Nobody has claimed this yet.
enhancement
- Dominant language
- JavaScript
- Stars
- 13k
- Forks
- 1.4k
- Avg merge
- 15h 36m
- Merged PRs (30d)
- 3
Description
Motivation
Now we cannot use Prism via ES Modules, because Prism is exported to only module.exports or global in prism-core.js. This restricts library usage in the following ways.
import Prism from 'https://example.com/path/to/prism.js';import('https://example.com/path/to/prism.js').then(Prism => ..);<script type="module" src="https://example.com/path/to/prism.js"></script>
Description
- How about separating
prism-core.jsinto the following files?prism-core.js: definesPrismobject and export default it. it does not do the browser-specific and Node.js-specific process. The filename can beprism.mjs.browser.js: importsprism.jsand do the browser-specific process such as highlighting automatically on DCL.cjs.js: importprism.jsand export it as CommonJS. but this file might be deprecated because of CommonJS-obsoletion in the future.
package.jsonfields will be:- "main": "prism.js",
- "module": "prism.js",
- Entry points will be:
https://unpkg.com/prismjs/prism.jsfor ES Moduleshttps://unpkg.com/prismjs/browser.jsfor Browsershttps://unpkg.com/prismjs/cjs.jsfor traditional Node.js
Contributor guide
No contributing guide indexed for this repository
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 with prism-core.js at the export logic around lines 614–621, then inspect package.json and the existing entry points. Compare how browser-specific and Node.js-specific behavior is currently handled with the proposed prism.js, browser.js, and cjs.js split. Done means ES module, browser, and CommonJS entry points work as described without breaking existing usage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100