[Request] Add Deno compatibility
See original GitHub issueIs your request related to a specific problem you’re having? I’d like to use this library in Deno (version 11.0.0). Due it uses standard ES modules, it should work fine, but there are some imports that are failing. For example here
Importing the code in Deno with:
import hljs from "https://cdn.jsdelivr.net/gh/highlightjs/highlight.js@11.0.0-beta1/src/highlight.js";
It throws the following error:
Download https://cdn.jsdelivr.net/gh/highlightjs/highlight.js@11.0.0-beta1/src/highlight.js
TypeError: Unmapped bare specifier "deep-freeze-es6"
This is because in Deno (and standard ES modules) all modules must be urls to files and this is a npm dependency.
The solution you’d prefer / feature you’d like to see added…
Due this is a very simple dependency, I propose to copy the dependency code to this repo, so it can be imported like any other ES module. It coud have its own file or be included in the lib/utils.js
:
import deepFreeze from './lib/utils.js';
Any alternative solutions you considered…
Maybe in the cdn-release repo, include also a ESM version with all extenal CJS dependencies converted to ESM.
Additional context…
FYI, I’m using lighlight.js in this plugin to highlight automatically all codes of html pages. I’m using a ESM conversion of v10 (with jspm.dev), but now that v11 is almost compatible, it would be awesome to make these changes so Deno users can import directly the original code.
Thanks!
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (6 by maintainers)
We’re quite happy with providing build assets for people and prefer that approach to our distributables. The repository source code is more for “internal use”, those building from source, doing very custom things, etc - it is not considered a distributable. Perhaps that will change one day in the shiny new ESM future, time will tell…
Ah I was reading a bit much into the title of your issue perhaps… if this is really merely “please provide a perfectly pure ESM” version (without the distractions of Node) then it is really a dup of #3199 and I will close it as such.
Lets focus on #3199. 😃
IMHO, a “pure ESM” (that works in both browser and Deno) would be the best solution. I’m not asking for a “Deno version”, but a ESM version that works for Deno.
That why I suggested that this repo could become that pure ESM version, so no need to built a different one, but if you think it’s better to have it in the CDN repo, that’s ok to me too.