Giter Site home page Giter Site logo

error with Deno final bundle! about otpauth HOT 3 CLOSED

hectorm avatar hectorm commented on May 9, 2024
error with Deno final bundle!

from otpauth.

Comments (3)

hectorm avatar hectorm commented on May 9, 2024

I was able to reproduce a similar error.

With the following code:

// @deno-types="https://deno.land/x/otpauth/types/index.d.ts"
import * as OTPAuth from 'https://deno.land/x/otpauth/dist/otpauth.esm.js';

let totp = OTPAuth.URI.parse('otpauth://totp/ACME:AzureDiamond?issuer=ACME&secret=NB2W45DFOIZA&algorithm=SHA1&digits=6&period=30');
console.log(totp);

When I run:

deno bundle ./app.ts ./app.bundle.js
deno run ./app.bundle.js

I get the following error:

error: Uncaught ReferenceError: parse is not defined
let totp = parse('otpauth://totp/ACME:AzureDiamond?issuer=ACME&secret=NB2W45DFOIZA&algorithm=SHA1&digits=6&period=30');
           ^
    at file:///home/hectorm/Projects/deno-otpauth/app.bundle.js:1512:12

However, if I change the way the module is imported, it works correctly.

// @deno-types="https://deno.land/x/otpauth/types/index.d.ts"
import { URI } from 'https://deno.land/x/otpauth/dist/otpauth.esm.js';

let totp = URI.parse('otpauth://totp/ACME:AzureDiamond?issuer=ACME&secret=NB2W45DFOIZA&algorithm=SHA1&digits=6&period=30');
console.log(totp);

Could you confirm whether the way OTPAuth is being imported is what is causing your error?

from otpauth.

 avatar commented on May 9, 2024

Yes, if i run this example with OTPAuth i see the error.

Screenshot with bundle and error
https://user-images.githubusercontent.com/75129392/102188550-c9992300-3ef8-11eb-9058-2e0bc3fc5111.jpg

Screenshot with bundle without error
https://user-images.githubusercontent.com/75129392/102188666-f2211d00-3ef8-11eb-8d06-3fdf0617afc6.jpg

please note the first line in the screenshot!

from otpauth.

hectorm avatar hectorm commented on May 9, 2024

In the first screenshot you should import the library like this (however, it will probably fail with the parse is not defined error):

import * as OTPAuth from './otpauth.js';

Anyway in my previous message I meant that you should try to change in your own code the way OTPAuth is imported based on the two examples I indicated. I suspect that it's a bug in Deno.

If you provide me with a test project that reproduces the problem it would be helpful.

from otpauth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.