From b30d8a1a542ebd6790ec6b20a7dfc58ebcbb952a Mon Sep 17 00:00:00 2001 From: devlux76 Date: Sun, 25 May 2025 22:43:57 -0600 Subject: [PATCH] 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. --- examples/extension/webpack.config.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/examples/extension/webpack.config.js b/examples/extension/webpack.config.js index ae71c9b11..827c14073 100644 --- a/examples/extension/webpack.config.js +++ b/examples/extension/webpack.config.js @@ -22,6 +22,26 @@ const config = { path: path.resolve(__dirname, 'build'), filename: '[name].js', }, + resolve: { + fallback: { + "fs": false, + "path": false, + "url": false, + } + }, + module: { + parser: { + javascript: { + importMeta: false, + }, + }, + }, + ignoreWarnings: [ + { + module: /node_modules\/@huggingface\/transformers/, + message: /Critical dependency: Accessing import\.meta directly is unsupported/, + }, + ], plugins: [ new HtmlWebpackPlugin({ template: './src/popup.html',