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

Webpack Errors from Middleware Imports #67260

Open
creativeindustriesgroup opened this issue Jun 28, 2024 · 0 comments
Open

Webpack Errors from Middleware Imports #67260

creativeindustriesgroup opened this issue Jun 28, 2024 · 0 comments
Labels
bug Issue was opened via the bug report template. Middleware Related to Next.js Middleware Webpack Related to Webpack with Next.js.

Comments

@creativeindustriesgroup
Copy link

creativeindustriesgroup commented Jun 28, 2024

Link to the code that reproduces this issue

https://github.com/creativeindustriesgroup/nextjs-webpack-middleware-issue

To Reproduce

When importing certain packages into middleware, accessing any page which triggers the middleware will throw the error:
./node_modules/farmhash-modern/bin/bundler/farmhash_modern_bg.wasm Module parse failed: Unexpected character '' (1:0) The module seem to be a WebAssembly module, but module is not flagged as WebAssembly module for webpack. BREAKING CHANGE: Since webpack 5 WebAssembly is not enabled by default and flagged as experimental feature. You need to enable one of the WebAssembly experiments via 'experiments.asyncWebAssembly: true' (based on async modules) or 'experiments.syncWebAssembly: true' (like webpack 4, deprecated). For files that transpile to WebAssembly, make sure to set the module type in the 'module.rules' section of the config (e. g. 'type: "webassembly/async"'). (Source code omitted for this binary file)

Current vs. Expected behavior

Packages such as firebase-admin, with-electron-typescript and mssql cannot be imported into middleware. I would expect these packages to be importable in order to perform operations such as token validation (in the case of firebase) in middleware.

Provide environment information

Operating System:
  Platform: darwin
  Arch: x64
  Version: Darwin Kernel Version 22.3.0: Mon Jan 30 20:42:11 PST 2023; root:xnu-8792.81.3~2/RELEASE_X86_64
  Available memory (MB): 32768
  Available CPU cores: 16
Binaries:
  Node: 20.13.1
  npm: 10.5.2
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 14.2.4 // Latest available version is detected (14.2.4).
  eslint-config-next: N/A
  react: 18.3.1
  react-dom: 18.2.0
  typescript: N/A
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Middleware, Webpack

Which stage(s) are affected? (Select all that apply)

next dev (local), next build (local)

Additional context

Issue seems similar in:

@creativeindustriesgroup creativeindustriesgroup added the bug Issue was opened via the bug report template. label Jun 28, 2024
@github-actions github-actions bot added Middleware Related to Next.js Middleware Webpack Related to Webpack with Next.js. labels Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. Middleware Related to Next.js Middleware Webpack Related to Webpack with Next.js.
Projects
None yet
Development

No branches or pull requests

1 participant