fix: resolve webpack import.meta warning in browser extension
- Add parser configuration to disable import.meta parsing in webpack
- Suppress critical dependency warnings from @huggingface/transformers
- Add Node.js fallbacks for browser compatibility (fs, path, url)
- Ensures clean build without warnings while maintaining ML functionality
- Extension now builds successfully for both development and production
Resolves webpack 5 compatibility issue with Transformers.js library when bundling for browser extension environment.
Hi there 👋 thanks for the PR!
We're in the process of moving our examples to https://github.com/huggingface/transformers.js-examples/tree/main/browser-extension; can you check if this is still an issue in that example? Thanks!
Hi! @xenova I just checked, and it is still an issue. I ran current "transformers.js-examples" and got this build error:
I also tried to apply changes suggested in this PR. the PR itself works, but it is missing the lines below when compared to the current "-extensions" solution.
alias: {
"@huggingface/transformers": path.resolve(
__dirname,
"node_modules/@huggingface/transformers",
),
},
when this is added (to match current "transformers.js-examples"), the error in the build.log above appears again.
there is actually a pull request in transformer.js-examples to fix this example:
https://github.com/huggingface/transformers.js-examples/pull/71