replicate-javascript icon indicating copy to clipboard operation
replicate-javascript copied to clipboard

alert message during build "require function is used in a way in which dependencies cannot be statically extracted"

Open jbilcke-hf opened this issue 8 months ago • 7 comments

Hello, for your information I get this message when I use the library in a Next project (replicate 0.30.2 with Next 14.2.3 or Next 14.2.4 - I haven't tested older combinations):

 ⚠ Compiled with warnings

./node_modules/replicate/lib/util.js
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

Import trace for requested module:
./node_modules/replicate/lib/util.js
./node_modules/replicate/index.js

I don't know exactly the consequences, my Next app seems to work just fine despite the scary "critical dependency" message, but you might still wanna check it out as other people might come across this too.

For a bit more context, I'm using a lot (90+) of other modules in the same project like langchain etc (I hope we will see a @langchain/replicate NPM module soon by the way) but none of them trigger this, so that's weird.

I'm using replicate on server-side not client-side (ie. I'm using it for Next's API endpoints) so it runs in a Node environment.

The tsconfig.json is like this if that can help:

{
  "compilerOptions": {
    "target": "ES2022",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "incremental": true,
    "plugins": [
      {
        "name": "next"
      }
    ],
    "paths": {
      "@/*": ["./src/*"]
    }
  },
  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
  "exclude": ["node_modules"]
}

jbilcke-hf avatar Jun 22 '24 11:06 jbilcke-hf