Thanks to visit codestin.com
Credit goes to github.com

Skip to content

serverExternalPackages config is only in dev mode and not used in build #74816

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

Closed
wmira opened this issue Jan 13, 2025 · 2 comments
Closed

serverExternalPackages config is only in dev mode and not used in build #74816

wmira opened this issue Jan 13, 2025 · 2 comments
Labels
Turbopack Related to Turbopack with Next.js. Webpack Related to Webpack with Next.js.

Comments

@wmira
Copy link

wmira commented Jan 13, 2025

Link to the code that reproduces this issue

https://github.com/wmira/nextexternalbug

To Reproduce

serverExternalPackages only getting used in dev mode. When on build, it totally ignores it and webpack throws an error.

  1. Clone this repo https://github.com/wmira/nextexternalbug
  2. cd server
    1. Notice that next.config.ts serverExternalPackages is configured
  3. npm install
  4. npm run dev
  5. go to http://localhost:3000 in your browser. Works fine.
  6. [optional] remove serverExternalPackages and do step 5 - 6. It will now throw error
  7. npm run build <-- error, if you did step 7, make sure to restore original next config

Is there an option to fully opt out of server-side code bundling?

npm run build error below.

./node_modules/@duckdb/node-bindings-linux-x64/duckdb.node
Module parse failed: Unexpected character '' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)

Import trace for requested module:
./node_modules/@duckdb/node-bindings-linux-x64/duckdb.node
./node_modules/@duckdb/ ./node_modules/@duckdb/ sync ^./node-bindings-.-./duckdb.node$
./node_modules/@duckdb/node-bindings/duckdb.js
./node_modules/@duckdb/node-api/lib/index.js
./src/app/page.tsx

Current vs. Expected behavior

npm run dev and npm run build should work the same way.

Provide environment information

OS: WSL

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

Developer Experience, Webpack, Turbopack

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

next build (local)

Additional context

No response

@wmira wmira added the bug Issue was opened via the bug report template. label Jan 13, 2025
@github-actions github-actions bot added Developer Experience Turbopack Related to Turbopack with Next.js. Webpack Related to Webpack with Next.js. labels Jan 13, 2025
@samcx samcx removed bug Issue was opened via the bug report template. Developer Experience labels Jan 16, 2025
@ZuBB
Copy link

ZuBB commented Feb 10, 2025

It looks like this also happens with Payload CMD and libsql.

payloadcms/payload#10941

@timneutkens
Copy link
Member

It looks like the package you're importing is @duckdb/node-api and there's other deps it tries to import are failing to resolve. But that also happens with Turbopack. It depends on if you're on macOS/Linux/Windows.

My recommendation would be adding @duckdb/node-api:

import type { NextConfig } from "next";

const nextConfig: NextConfig = {
  serverExternalPackages: ["@duckdb/node-api"],
};

export default nextConfig;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Turbopack Related to Turbopack with Next.js. Webpack Related to Webpack with Next.js.
Projects
None yet
Development

No branches or pull requests

4 participants