Skip to content

Transformers.js in chrome extension fails to execute remote code served from https://cdn.jsdelivr.net/npm/@huggingface/[email protected]/dist/ort-wasm-simd-threaded.jsep.mjs #1248

@mattmacf98

Description

@mattmacf98

System Info

Hi I was attempting to build a chrome extension using @huggingface/transformers, I ran into a problem where chrome extensions are not allowed to load code from remotely hosted code. So when initializing, I get problems loading https://cdn.jsdelivr.net/npm/@huggingface/[email protected]/dist/ort-wasm-simd-threaded.jsep.mjs

Error in worker: Error: no available backend found. ERR: [wasm] TypeError: Failed to fetch dynamically imported module
and then I try to add the cdn url to my manifest of allowed script-src I get and Insecure CSP value since manifest v3 prohibits these now.

I think I could get around this by downloading the cdn file locally and bundling with my extension, but I am unsure how to then tell hugging face to use the local mjs instead of going to the CDN.

I noticed that in the legacy version of this repo @xenova/transformers, https://github.com/huggingface/transformers.js/tree/main/examples/extension the extension works properly! and I verified that switching to that repo fixed my issue.

Would it be possible to have @huggingface/transformers or make the url configurable so i can point to a local bundled js if I want to?

Who can help?

@Rocketknight1

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

Steps to reproduce:

  1. clone https://github.com/huggingface/transformers.js/tree/main/examples/extension
  2. build and see that it works!
  3. switch to use huggingface/transformers -> see that it does not work since the CDN is blocked

Expected behavior

I expect to be able to run the model without having to get ort-wasm-simd-threaded.jsep.mjs from a CDN at runtime

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions