-
-
Notifications
You must be signed in to change notification settings - Fork 416
Description
Issue Description
When importing Human on a NextJS 14 project, the framework tries to import the node bundle instead of ESM for browsers, despite adding 'use client' on top of the page file.
Since node bundle requires a tfjs backend, the error below comes in:
./node_modules/@vladmandic/human/dist/human.node.js:7:1678
Module not found: Can't resolve '@tensorflow/tfjs-node'
I know that this is not an issue within the Human package at all and it's about NextJS SSR. However I guess you may help me to achieve the desired solution.
I already tried to load Human within a separated dynamic loaded component with dynamic(() => import('@/components/Human'), { ssr: false }), but it also did not work.
I also tried to import it inside a useEffect of the Human component created as you did in your class constructor in NextJS demo, but it also did not work.
I also tried to import Human explicitly from @vladmandic/human/dist/human.esm but it did not found the path.
Everything works fine if I use Vite instead of NextJS to create my project.
Steps to Reproduce
- Create a new project with
npx create-next-app app-nameand choose all default configs. - Run
npm i - Change
app/page.tsxto add'use client'on top the file and add import to Humanimport { Human } from '@vladmandic/human. - Run
npm run dev - Access the URL on your browser
Expected Behavior
NextJS identify that I'm using a client component on that page and load ESM bundle of Human package instead of node bundle.
Environment
- Human library version? 3.2.0
- Built-in demo or custom code? Custom code. Just create a project and import Human.
- Type of module used (e.g.
js,esm,esm-nobundle)? esm - TensorFlow/JS version (if not using bundled module)?
- Browser or NodeJS and version (e.g. NodeJS 14.15 or Chrome 89)? Arc 1.28.0
- OS and Hardware platform (e.g. Windows 10, Ubuntu Linux on x64, Android 10)? macOS 14.2.1 on M2 Pro (arm64)
- Packager (if any) (e.g, webpack, rollup, parcel, esbuild, etc.)?
- Framework (if any) (e.g. React, NextJS, etc.)? NextJS
Diagnostics
- Check out any applicable diagnostic steps
Additional
- For installation or startup issues include your
package.json - For usage issues, it is recommended to post your code as gist
- For general questions, create a discussion topic