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

Next.js 14 Thin mode: Critical dependency #1678

Closed
saphitv opened this issue Jun 13, 2024 · 4 comments
Closed

Next.js 14 Thin mode: Critical dependency #1678

saphitv opened this issue Jun 13, 2024 · 4 comments
Labels

Comments

@saphitv
Copy link

saphitv commented Jun 13, 2024

  1. What versions are you using?
    database version: 19.0.0
    platform: win32
    node version: v21.4.0
    arch: x64
    library version: 6.5.1

  2. Describe the problem
    When I do a build of a nextjs application with oracledb in Thin mode I get build warnings.

./node_modules/oracledb/lib/oracledb.js
Dependency critical: the require function is used in such a way that dependencies cannot be extracted statically.

Track the import of the require module:
./node_modules/oracledb/lib/oracledb.js
./node_modules/oracledb/index.js
./src/actions/others.ts
./src/components/view/topbar/top-bar.tsx
./src/app/page.tsx

The file that is shown performs this simple import (I don't think import is the problem):
import { BIND_OUT, CLOB, STRING} from "oracledb";

Is there any way to resolve this warning?

@sosoba
Copy link

sosoba commented Jun 13, 2024

IMHO you should use CommonJS default import:

import oracledb from 'oracledb';

const { BIND_OUT, CLOB, STRING } = oracledb;

@saphitv
Copy link
Author

saphitv commented Jun 13, 2024

Hi, unfortunately I had already tried this since I originally thought it was a problem with the import. I tried again now but the problem persists

@sharadraju
Copy link
Member

@saphitv We are not able to replicate this issue.
Can you provide a sample code that reproduces this issue.

@sharadraju
Copy link
Member

Since Next.js uses webpack, This warning is thrown. This has already been documented here:
https://medium.com/oracledevs/bundling-node-oracledb-javascript-apps-with-webpack-597c452f71f

The ‘Critical dependency’ warning can be ignored. It occurs because Webpack is unable to analyze the Thick mode binary that node-oracledb optionally loads with require() so Webpack can’t see if there are any further dependencies. Since the demo isn’t using Thick mode, this warning is not an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants