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

deno bundle doesn't work on mod.ts #39

Closed
alexanderGalushka opened this issue Nov 7, 2020 · 18 comments
Closed

deno bundle doesn't work on mod.ts #39

alexanderGalushka opened this issue Nov 7, 2020 · 18 comments

Comments

@alexanderGalushka
Copy link

tried deno 1.5.1 all the way down to 1.0.0 - no luck

getting rid of _deps.ts and putting decodeString and encodeToString directly from deno encoding lib for each module _signature.ts and mod.ts make the bundle work fine

@timonson
Copy link
Member

timonson commented Nov 7, 2020

I don't think this is an issue for this library. I think it would be great if you would open this issue in the deno repo.

@alexanderGalushka
Copy link
Author

Currently djwt can not be bundled. Libraries bundling is a common and widely used Deno feature. I agree it might not be an issue with the djwt library itself, but an easy work around can be implemented, see the suggested fix above.

I think bundle doesn't work well with circular dependencies. I will definitely submit an issue with Deno itself.

But just food for thought, is _deps.ts really needed for djwt? If you strongly believe that it does, I'd like to understands what are the benefits so the broken Deno bundle of djwt library can be justified.

@alexanderGalushka
Copy link
Author

alexanderGalushka commented Nov 7, 2020

Deno bundle command doesn't error out but the bundled code doesn't contain the implementation for convertUint8ArrayToHex

which is essentially encodeToString function from "https://deno.land/[email protected]/encoding/hex.ts"

that's how issue manifests itself:

ReferenceError: convertUint8ArrayToHex is not defined

@bicarlsen
Copy link

Just started with Deno, so not sure if I can provide much insight, but I am receiving the error:

An unsupported media type was attempted to be imported as a module.
Specifier: https://deno.land/[email protected]/djwt/mod.ts
MediaType: Unknown

when running import { create } from 'https://deno.land/[email protected]/djwt/mod.ts'; which seems related to this.

@timonson
Copy link
Member

timonson commented Nov 8, 2020

What exactly do I have to do in order to replicate this?

@alexanderGalushka
Copy link
Author

@timonson I've put together a quick test, follow the readme steps to reproduce https://github.com/alexanderGalushka/djwt_test

@bicarlsen
Copy link

What exactly do I have to do in order to replicate this?
For me it occurs any try to import it, even if it is the only thing in the file.

i.e.
test.ts

import { create } from 'https://deno.land/[email protected]/djwt/mod.ts';

Then running

deno run test.ts

results in the error

error: An unsupported media type was attempted to be imported as a module.
Specifier: https://deno.land/[email protected]/djwt/mod.ts
MediaType: Unknown

@timonson
Copy link
Member

@bicarlsen it seems you are using a wrong url. Try this one: https://deno.land/x/[email protected]/mod.ts

@bicarlsen
Copy link

Great! That resolved the loading issue. Just a heads up, that URL was copied from the README on the deno.land page.

@alexanderGalushka
Copy link
Author

@timonson were you be able to reproduce deno bundle issue?

@timonson
Copy link
Member

timonson commented Nov 12, 2020

Yes I was and it seems to be a deno bundle bug. I would suggest that we wait a couple of more days and see if this swc-project/swc#1212 will fix it. Are you OK with this idea?

@alexanderGalushka
Copy link
Author

totally

@BayoKwendo
Copy link

warning: Compiled module not found "https://deno.land/x/[email protected]/mod.ts"
From: file:///home/bayo/Work/themeforest/Insight/controllers/authController.ts
If the source module contains only types, use import type and export type to import it instead.
error: Uncaught SyntaxError: The requested module 'https://deno.land/x/[email protected]/mod.ts' does not provide an export named 'create

@timonson
Copy link
Member

timonson commented Nov 14, 2020

Hi @BayoKwendo , this seems to be a deno issue as well. Please take a look at this issue here #37 . I would guess there is a caching problem.

@timonson
Copy link
Member

Hi @alexanderGalushka , I believe this issue has been fixed now or am I wrong?

@alexanderGalushka
Copy link
Author

alexanderGalushka commented Nov 25, 2020

I just upgraded to deno v1.5.4, would like to test it out

deno bundle "https://deno.land/x/[email protected]/mod.ts" djwt.js

getting the following error:

Bundle https://deno.land/x/[email protected]/mod.ts
Check https://deno.land/x/[email protected]/mod.ts
error: No such file or directory (os error 2)

@timonson can u please try to bundle as well to confirm

@timonson
Copy link
Member

I tried your test out before I asked the question and it worked for me.
The single command deno bundle "https://deno.land/x/[email protected]/mod.ts" djwt.js works without error on my linux machine, too. Maybe try the --reload option?

@alexanderGalushka
Copy link
Author

@timonson seems to be working

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

No branches or pull requests

4 participants