Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module crashes webpack build due to use of new URL('./', import.meta.url) #984

Open
1 of 5 tasks
Onekki opened this issue Oct 21, 2024 · 4 comments
Open
1 of 5 tasks
Labels
bug Something isn't working

Comments

@Onekki
Copy link

Onekki commented Oct 21, 2024

System Info

transformer.js#3

Environment/Platform

  • Website/web-app
  • Browser extension
  • Server-side (e.g., Node.js, Deno, Bun)
  • Desktop app (e.g., Electron)
  • Other (e.g., VSCode extension)

Description

The dist folder of transformer.js in node_modules contains the "new URL('./', import.meta.url)", which cause a build crash for webpack:
webpack/webpack#16878

Reproduction

extension.zip

@Onekki Onekki added the bug Something isn't working label Oct 21, 2024
@MrShahzeb-kresus
Copy link

MrShahzeb-kresus commented Oct 22, 2024

Facing this issue on expo react native

"expo": "~51.0.28",
"react": "18.2.0",
"react-native": "0.74.5",
"@xenova/transformers": "^2.17.2",

SyntaxError: 192689:107:'import.meta' is currently unsupported, js engine: hermes [Component Stack]

@timi137137
Copy link

facing this issue on next v14

"@huggingface/transformers": "^3.0.0",
"next": "14.2.5",
"react": "^18",
"react-dom": "^18",
 ⨯ ./node_modules/@huggingface/transformers/dist/transformers.js:32776:1
Module not found: Can't resolve './'

@xenova
Copy link
Collaborator

xenova commented Oct 22, 2024

Hi there 👋 Thanks for reporting - we're working on fixing this :)

In the meantime, there is a workaround as shown here
(update the webpack config):

webpack(config, { isServer }) {
	config.resolve.alias['@huggingface/transformers'] = path.resolve(__dirname, 'node_modules/@huggingface/transformers');
        .... 
	return config;
	}

@xenova
Copy link
Collaborator

xenova commented Oct 23, 2024

I might have found a better solution (tested in Next.js v15):

const nextConfig = {
  output: "standalone",
  // https://nextjs.org/docs/app/api-reference/next-config-js/serverExternalPackages
  serverExternalPackages: ["@huggingface/transformers"],
};

Let me know if that fixes it!


Demo: https://huggingface.co/spaces/webml-community/next-server-template
Source code: https://github.com/huggingface/transformers.js-examples/tree/main/next-server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants