Skip to content

[Question] ESM module import in the browser (via jsdelivr) #92

@josephrocca

Description

@josephrocca

Wondering how to import transformers.js as a module (as opposed to <script>) in the browser? I've tried this:

let { AutoTokenizer } = await import("https://cdn.jsdelivr.net/npm/@xenova/[email protected]/dist/transformers.min.js");

But it doesn't seem to export anything. I might be making a mistake here, but if not: Woudl it be possible to get a module-based js file for the browser?


Also, as an aside, can I suggest using a versioned URL in the readme? Or something like:

https://cdn.jsdelivr.net/npm/@xenova/[email protected]/dist/transformers.min.js

With a note telling them to replace X.Y.Z with the latest version. This allows you to make breaking changes in the future without breaking a bunch of sites. Often newbie devs don't realise that they have to swap for a versioned URL, and this can lead to "web rot" where old webpages eventuallly become broken or buggy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions