question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Request] Add Deno compatibility

See original GitHub issue

Is 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:closed
  • Created 2 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
joshgoebelcommented, May 30, 2021

That why I suggested that this repo could become that pure ESM version

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…

I’m not asking for a “Deno version”, but a ESM version that works for Deno.

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. 😃

0reactions
oscaroterocommented, May 30, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node.js compatibility mode | Manual - Deno
Starting with v1.15 Deno provides Node compatiblity mode that makes it possible to run a subset of programs authored for Node.js directly in...
Read more >
Compatibility with deno · Issue #1661 · yargs/yargs - GitHub
Hi guys, Do you have any plans to add compatibility for deno? The 1.0.0 is out so it's a good time to think...
Read more >
Node.js compatibility in Deno | The JS runtimes - Medium
The compatibility mode allows CJS (common JS) modules to get loaded through require() API. Unlike standard imports that don't require a read permission,...
Read more >
Node.js rival Deno adds stable npm compatibility in effort to ...
No node_modules directory is required. Node.js itself uses a node_modules directory in the application source. The team confesses though that “ ...
Read more >
Writing Deno/Node Cross-Compatible Javascript
Note: Not long after publish Deno 1.15 added several new ... We can call this import-map-deno.json and we can tell Deno to run...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found