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

Feature/esmbuild #71

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Hexagon
Copy link

@Hexagon Hexagon commented Apr 18, 2022

  • Create bundled es-module build/asn1.bundle.mjs for simple browser usage, and Deno support.

  • Add basic installation instructions

  • Include build/* in repo for certain cdn-providers, e.g. deno.land/x or jsdeliver/gh

@microshine
Copy link
Contributor

microshine commented Apr 18, 2022

I don't like the idea of keeping bundled (compiled) files in repo.

unpkg cdn-provider allows to use this module without minification

import * as asn1js from "https://unpkg.com/asn1js?module";

@Hexagon
Copy link
Author

Hexagon commented Apr 18, 2022

Unpkg works great for me, thanks again for the tip.

Having a "standardised" bundle in repo would serve a purpose anyways, enabling all cdn providers to serve the bundle.

If that's not interesting, maybe we can revert the gitignore change but still build the bundle? (and let npm be the source of choice for Deno, and simplify browser usage)

That would make this work:

import { x } from "https://cdn.jsdelivr.net/npm/asn1js@2/build/asn1.bundle.mjs";

Edit: Force pushed a new version of this pull request, without repo-inclusion of build/.

@microshine
Copy link
Contributor

I've published asn1js@3.0.0. Please try it.

HTML

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script type="module">
    import * as asn1js from "https://unpkg.com/asn1js?module";

    const asn = new asn1js.Utf8String({
      value: "Hello world",
    });

    console.log(asn.toString()); // ascii
    console.log(asn.toString("hex"));
  </script>
</body>

</html>

Console

UTF8String : 'Hello world'
index.html:20 0c0b48656c6c6f20776f726c64

I don't like the idea of keeping the bundle file with included external dependencies in the NPM registry. I guess it's better to compile a bundle file on application later with env requirements.

@Hexagon
Copy link
Author

Hexagon commented May 12, 2022

@microshine

Upgraded fido2-lib @ webauthn-open-source/fido2-lib#85 . Works fine!

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 this pull request may close these issues.

None yet

2 participants