Deno is not listed in deno.land importable modules: https://github.com/denoland/deno_website2/blob/master/src/database.json
I tried Pika CDN:s which tries to support Deno for NPM-modules
$ cat fp-ts-log.ts
import { log } from 'https://cdn.pika.dev/fp-ts/Console';
log("hello!")();
$ deno --reload fp-ts-log.ts
Compile file:///Users/petri/code/pe3/how-to/programming/deno/fp-ts-log.ts
Download https://cdn.pika.dev/fp-ts/Console
Download https://cdn.pika.dev/-/[email protected]/dist=es2019,Console/fp-ts.js
Download https://cdn.pika.dev/-/[email protected]/dist=es2019,Console/fp-ts.js
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/index.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/index.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Alt.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Alternative.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Applicative.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Apply.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Array.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Bifunctor.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/boolean.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/BooleanAlgebra.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Bounded.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/BoundedDistributiveLattice.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/BoundedJoinSemilattice.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/BoundedLattice.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/BoundedMeetSemilattice.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Category.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Chain.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/ChainRec.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Choice.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Comonad.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Compactable.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Console.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Const.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Contravariant.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Date.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/DistributiveLattice.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Either.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/EitherT.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Eq.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Extend.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Field.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Filterable.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/FilterableWithIndex.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Foldable.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/FoldableWithIndex.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/function.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Functor.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/FunctorWithIndex.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Group.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/HeytingAlgebra.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/HKT.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Identity.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Invariant.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/IO.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/IOEither.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/IORef.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/JoinSemilattice.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Lattice.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Magma.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Map.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/MeetSemilattice.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Monad.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/MonadIO.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/MonadTask.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/MonadThrow.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Monoid.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/NonEmptyArray.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Option.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/OptionT.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Ord.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Ordering.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/pipeable.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Profunctor.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Random.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Reader.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/ReaderEither.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/ReaderT.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/ReaderTask.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/ReaderTaskEither.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Record.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Ring.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Semigroup.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Semigroupoid.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Semiring.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Set.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Show.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/State.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/StateReaderTaskEither.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/StateT.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Store.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Strong.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Task.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/TaskEither.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/TaskThese.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/These.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/TheseT.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Traced.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Traversable.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/TraversableWithIndex.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Tree.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Tuple.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Unfoldable.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/ValidationT.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Witherable.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/Writer.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/WriterT.d.ts
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/types/HKT
error: Uncaught Other: Import 'https://cdn.pika.dev/-/[email protected]/dist=es2019/types/HKT' failed: 404 Not Found
► $deno$/dispatch_json.ts:40:11
at DenoError ($deno$/errors.ts:20:5)
at unwrapResponse ($deno$/dispatch_json.ts:40:11)
at sendAsync ($deno$/dispatch_json.ts:91:10)
these didn't work either
// Uncaught Other: Import 'https://cdn.pika.dev/-/[email protected]/dist=es2019,lib/Console' failed: 404 Not Found
// import { log } from 'https://cdn.pika.dev/fp-ts/lib/Console';
// Uncaught Other: Import 'https://cdn.pika.dev/-/[email protected]/dist=es2019,es6/Console' failed: 404 Not Found
// import { log } from 'https://cdn.pika.dev/fp-ts/es6/Console';
I would want to write import { log } from 'https://some-module-registry/fp-ts/Console';
Add fp-ts to database.json
This would make it effortless to evaluate fp-ts if you have Deno installed.
The Pika CDN tries to support Deno. If deno.land import doesn't work that would be another option.
| Software | Version(s) |
| ---------- | ---------- |
| fp-ts | 2.4.4 |
| TypeScript | 3.6.4 |
I made a PR to the Deno package database.json https://github.com/denoland/deno_website2/pull/236
I set the registry name for fp-ts to be fp_ts since dashes are not allowed.
Hi @pe3
I'm not sure I'm following what you're suggesting. What kind of work is required on fp-ts side?
@raveclassic I'm not aware of any work required (but that doesn't mean there isn't something). I created this issue before I realized I can do a PR to add fp-ts to the database myself. After doing it I still thought that maybe it is better to make the fp-ts-team aware of my PR to denoland.
So if there's no work required on fp-ts side, no issue/bug to track, I think we could safely close this issue. Do you agree?
I don't know if Deno requires the library to be implemented certain way. I haven't been able to test if the import through deno.land database.json will work or not. I can for sure report that the Pika CDN was not automatically able to serve fp-ts for Deno (see CLI output above - it failed at HKT). It is up to you how you frame the project. If you want to support Deno use or not.
I don't think fp-ts needs to change its implementation.
For testing fp-ts with deno I patched fp-ts manually and at some point the same error occurred for me.
To make thing work for deno, it seems Pika CDN patches import statements to add .ts at the end of the path. Problem is fp-ts has a few declare module 'fp-ts/lib/HKT' calls in its source. When not patched to include .ts at the end of the path, the error occurs. You can see it in the error message, which reads error: Uncaught Other: Import 'https://cdn.pika.dev/-/[email protected]/dist=es2019/types/HKT' failed: 404 Not Found when actually it shoud try to load https://cdn.pika.dev/-/[email protected]/dist=es2019/types/HKT.d.ts. Notice the d.ts on the end of the path. In fact deno even loaded https://cdn.pika.dev/-/[email protected]/dist=es2019/types/HKT.d.ts before, because it was found as an import somewhere.
So it seems it's Pika CDN, who might have to figure out what to do with declare module statements. Otherwise fp-ts and most likely other modules won't load for deno. Since I cannot find a repo to file an issue for Pika CDN, I'll try to comment on the blog post.
Thanks @tmueller ! I came to the same conclusion but got scared this issue is snowballing and I don't have the time at the moment. For the record: @tmueller's comment is here https://dev.to/tmueller/comment/lcli
Awesome work for deno 👍
Would you be so kind to have a look at github.com/gcanti/fp-ts/issues/113...? Pika CDN seems to patch import statements for deno correctly. But it seems declare module '...' statements are not patched. This might be the reason some modules won't load for deno. fp-ts for example. Thank you :)
Pika CDN seems to be the right place to solve the problem. Theoretically this could maybe be solved by writing:
// @ts-ignore
declare module 'fp-ts/lib/HKT.ts'
However I think disabling the compiler is against the spirit of typed FP and I'm not proposing doing it.
Hey everyone! Fred from the Pika CDN here. Just responding to Thomas's comment on the dev.to post:
This was a good catch. It looks like we weren't rewriting those declare module specifiers along with the import specifiers, even though they needed the rewrite just as much. I just pushed a fix for this, and you can now import fp-ts from the Pika CDN successfully!
$ cat test.ts
import {array} from 'https://cdn.pika.dev/fp-ts@^2.4.4';
console.log('Done:', array);
$ deno test.ts
Compile file:///Users/fks/Code/pika-tools/snowpack/test.ts
Download https://cdn.pika.dev/fp-ts@^2.4.4
Download https://cdn.pika.dev/-/[email protected]/dist=es2019/fp-ts.js
...
Done: { URI, getShow, getMonoid, ... }
Note: If you tried this before the fix when things were broken, you may need to run deno with the --reload flag the first time you re-try it now.
One other quick thing: imports from the Pika CDN should almost always be from the main package entrypoint. We'll be implementing package.json export map support for projects that need it, but that is still experimental and won't be baked into the ecosystem for quite some time.
On the day that the OP was created, that import was silently broken (was loading the main package, not any Console file) and today it fails with a 404.
- import { log } from 'https://cdn.pika.dev/fp-ts/Console';
+ import { console } from 'https://cdn.pika.dev/fp-ts';
Thanks @FredKSchott for implementing the change that fast :) Works for me now. Also thanks @pe3 for starting this thread. From a fp-ts perspective this could be closed now.
I just tried @FredKSchott's example above with deno version 0.34.0 and I wasn't able to compile it. The errors were as follows:
error TS2614: Module '"https://cdn.pika.dev/fp-ts@^2.4.4"' has no exported member 'array'. Did y
ou mean to use 'import array from "https://cdn.pika.dev/fp-ts@^2.4.4"' instead?
► file:///home/cdimitroulas/code/cdimitroulas/assessment-centre-deno/src/deps.ts:1:9
1 import {array} from 'https://cdn.pika.dev/fp-ts@^2.4.4';
~~~~~
error TS2307: Cannot find module '/-/[email protected]/dist=es2019/fp-ts.js'.
► https://cdn.pika.dev/fp-ts@^2.4.4:23:15
23 export * from '/-/[email protected]/dist=es2019/fp-ts.js';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error TS2307: Cannot find module '/-/[email protected]/dist=es2019/fp-ts.js'.
► https://cdn.pika.dev/fp-ts@^2.4.4:24:23
24 export {default} from '/-/[email protected]/dist=es2019/fp-ts.js';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Found 3 errors.
I can confirm as well, this is working in v0.33.0 but is broken in v0.34.0. Seems like something broke with how they resolve remove imports in the latest version.
https://github.com/denoland/deno/issues/4117
Filed this so that they're aware, but for now I'd recommend using Deno v0.33.0 until this bug is fixed.
Most helpful comment
Hey everyone! Fred from the Pika CDN here. Just responding to Thomas's comment on the dev.to post:
This was a good catch. It looks like we weren't rewriting those declare module specifiers along with the import specifiers, even though they needed the rewrite just as much. I just pushed a fix for this, and you can now import fp-ts from the Pika CDN successfully!
Note: If you tried this before the fix when things were broken, you may need to run deno with the
--reloadflag the first time you re-try it now.