Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error importing @substrate/smoldot-light from esm.sh in deno #2962

Closed
btwiuse opened this issue Nov 2, 2022 · 3 comments · Fixed by #2964
Closed

Error importing @substrate/smoldot-light from esm.sh in deno #2962

btwiuse opened this issue Nov 2, 2022 · 3 comments · Fixed by #2964

Comments

@btwiuse
Copy link

btwiuse commented Nov 2, 2022

Hi, I'm trying to use https://deno.land/x/polkadot in latest deno, which depends on @substrate/smoldot-light.

$ deno --version
deno 1.27.0 (release, x86_64-unknown-linux-gnu)
v8 10.8.168.4
typescript 4.8.3

I have three files:

$ more polkadot-0.2.1*|cat
::::::::::::::
polkadot-0.2.11.ts
::::::::::::::
import "https://deno.land/x/polkadot@0.2.11/api/mod.ts";
::::::::::::::
polkadot-0.2.12.ts
::::::::::::::
import "https://deno.land/x/polkadot@0.2.12/api/mod.ts";
::::::::::::::
polkadot-0.2.13.ts
::::::::::::::
import "https://deno.land/x/polkadot@0.2.13/api/mod.ts";

the first works:

$ deno run -A polkadot-0.2.11.ts 

the rest don't:

$ deno run -A polkadot-0.2.12.ts 
error: Uncaught SyntaxError: The requested module 'https://deno.land/std@0.153.0/node/process.ts' does not provide an export named 'hrtime'
    at <anonymous> (https://esm.sh/v96/@substrate/smoldot-light@0.7.2/deno/smoldot-light.js:4:5277)

$ deno run -A polkadot-0.2.13.ts 
error: Uncaught SyntaxError: The requested module 'https://deno.land/std@0.153.0/node/process.ts' does not provide an export named 'hrtime'
    at <anonymous> (https://esm.sh/v96/@substrate/smoldot-light@0.7.2/deno/smoldot-light.js:4:5277)

This issue makes 0.2.12 and 0.2.13 releases of https://deno.land/x/polkadot unusable.

Also @jacogr, can we switch to https://deno.land/x/smoldot@light-js-deno-v0.7.5 instead of relying on esm.sh?

@tomaka
Copy link
Contributor

tomaka commented Nov 2, 2022

I guess the problem is that the std/node library of Deno (supposed to provide equivalents to NodeJS) doesn't support hrtime.

The actual NodeJS module: https://nodejs.org/api/process.html
Deno compatibility status: https://deno.land/std@0.161.0/node/process.ts

@tomaka
Copy link
Contributor

tomaka commented Nov 2, 2022

I tracked down why we are using hrtime instead of performance.now(), and it seems that it was because we used to use the https://www.npmjs.com/package/performance-now library, which uses hrtime.

Since performance.now() has been available since NodeJS 8.5, I guess it's fine to use it.

tomaka added a commit to tomaka/substrate-lite-1 that referenced this issue Nov 2, 2022
@tomaka tomaka mentioned this issue Nov 2, 2022
@jacogr
Copy link

jacogr commented Nov 2, 2022

There are some parts of deno.land/x/polkadot (not enough as of yet) that do indeed import from deno.land/* instead of via esm.sh (I have been holding off on using npm:* for these esm.sh/* occurrences, at some point it will/should be swapped)

In this specific case, the JS API is an indirect consumer, we are using/importing @substrate/connect which in turn uses smoldot under the hood, so we cannot quite add that replacement to the deno build process.

@mergify mergify bot closed this as completed in #2964 Nov 4, 2022
mergify bot added a commit that referenced this issue Nov 4, 2022
Fix #2962

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants