retextjs / retext

natural language processor powered by plugins part of the @unifiedjs collective
https://unifiedjs.com
MIT License
2.36k stars 93 forks source link

Deno with esm.sh #72

Closed ralyodio closed 2 years ago

ralyodio commented 2 years ago

Initial checklist

Problem

error: Import 'https://cdn.esm.sh/v57/nlcst-to-string@2.0.4/es2021/nlcst-to-string.js' failed: 408 Request Timeout at https://cdn.esm.sh/v57/parse-latin@5.0.0/es2021/parse-latin.js:2:27264

Deosn't seem to work with Deno yet.

Solution

support Deno

Alternatives

https://esm.sh

wooorm commented 2 years ago

That looks like an esm.sh bug? Maybe report it there? The error message also says they’re working on it?

ralyodio commented 2 years ago

Oh you know my internet was flaky. Let me try again

chovyprognos commented 2 years ago

Still not working. its not my internet.

ChristianMurphy commented 2 years ago

I tried opening an interactive deno shell, and entered:

import {retext} from 'https://cdn.skypack.dev/retext@8.1.0?dts'

retext.parse('an example sentence')

it worked fine, this issue is specific to esm.sh not retext.

github-actions[bot] commented 2 years ago

Hi! This was closed. Team: If this was fixed, please add phase/solved. Otherwise, please add one of the no/* labels.

github-actions[bot] commented 2 years ago

Hi team! Could you describe why this has been marked as external?

Thanks, — bb

ChristianMurphy commented 2 years ago

This was logged as https://github.com/alephjs/esm.sh/issues/215

ralyodio commented 2 years ago

How do I load retextPos and retextKeywords from skypack?

wooorm commented 2 years ago

That sounds like a question either for skypack, or for deno folks.

ChristianMurphy commented 2 years ago

@ralyodio skypack works largely the same as esm.sh, it uses the url structure https://cdn.skypack.dev/ add the npm package name @ npm version ?dts.

So it would look like:

import retextKeywords from 'https://cdn.skypack.dev/retext-keywords@7.1.0?dts'
import retextPos from 'https://cdn.skypack.dev/retext-pos@4.1.0?dts'

checking with an interactive deno session, it looks like a nested package under retext-pos is having an issue with skypack.

[Package Error] "pos@v0.4.2" could not be built. 
Uncaught Error: [Package Error] "pos@v0.4.2" could not be built. 
    at https://cdn.skypack.dev/error/build:pos@v0.4.2-CpR50sqbM07FaeuJMu2I:13:7

It may be worth floating that to the skypack folks to get a better understand of what the Internal server error is, and whether it can be fixed on skypack. FWIW, esm.sh also seems to be failing on retext-pos, likely on pos, but it gives a vague timeout error.

It may be worth checking some other CDNs, including: https://unpkg.com/, https://www.jsdelivr.com/esm, https://jspm.org/, etc

Another option would not using a CDN, and using a unbundled build tool like snowpack https://www.snowpack.dev/concepts/how-snowpack-works to generate an ESM friendly web_modules folder (snowpack is a wrapper around https://www.npmjs.com/package/esinstall).

ChristianMurphy commented 2 years ago

Another note worth adding, typescript in deno has it's limitations currently, specifically handling ambient types, like those from definitely typed. Skypack is aware https://github.com/skypackjs/skypack-cdn/issues/116, and they (and likely other CDNs) appear to be waiting for the outcome of https://github.com/microsoft/TypeScript/issues/28985 (and maybe https://github.com/microsoft/TypeScript/issues/35749) to decide how to handle this situation. In the meantime, deno run --no-check {file-name} is an option if an npm package which depends on things like @types/unist or @types/nlcst, which retext, unified, and vfile do.