Open firdausai opened 1 month ago
I have pinpoint the problem to esbuild. This line of code is the issue
@xenova/transformers/src/env.js
const __dirname = RUNNING_LOCALLY
? path.dirname(path.dirname(url.fileURLToPath(import.meta.url)))
: './';
the current esbuild config change import.meta.url
into import_meta.url
. However, this was fixed by changing some setting as per this github discussion.
https://github.com/evanw/esbuild/commit/ac97be74c3b5453740f84fc40098ccae95cde19f
...
The `import.meta` syntax is now passed through unmodified when the target is `es2020` or newer and the output format is `esm`. This lets you use features such as `import.meta.url` in those situations.
This worked and it doesn't change the variable anymore. However, since I changed the output format, I come across a new error, which prevents me from using import
and require me to use required()
when importing a module. So far, only transformers/src/env.js
amd transformers/src/utils/hub.js
used import
, so I change them manually in the output dir (not ideal, but I just want to see if it would work). It did work, but now I ran into another issue and have this error Cannot use 'import.meta' outside a module
. This is where I am still stuck.
Please refer https://github.com/microsoft/onnxruntime/pull/20165#issuecomment-2311564377. More discussion there is welcome. Thanks!
System Info
"@xenova/transformers": "^2.17.2" Electron (Obsidian.md)
Environment/Platform
Description
I am trying to build an obsidian.md plugin, where I want to load a local model (or hosted on huggingface is fine too) using transformer.js. I went through several issues.
The "path" argument must be of type string or an instance of URL. Received undefined
.Not sure if its a pure transformer.js or it is caused something by changing the target build.
Code in question:
I also tried other pipeline value like below, but the error is still the same:
Reproduction
const classifier = await pipeline('sentiment-analysis'); const output = await classifier('I love transformers!');
inMyPlugin
class.