vercel / next.js

The React Framework
https://nextjs.org
MIT License
126.88k stars 26.97k forks source link

[Turbopack] [Next 15 RC] Cannot resolve exported paths from `@skeletonlabs/skeleton@next` #66887

Closed eagerestwolf closed 4 months ago

eagerestwolf commented 4 months ago

Link to the code that reproduces this issue

https://github.com/eagerestwolf/nextjs-turbopack-import-bug

To Reproduce

  1. Create a new application using create-next-app@rc, enabling Turbopack
  2. Install @skeletonlabs/skeleton@next
  3. Attempt to import the Skeleton Tailwind plugin

Current vs. Expected behavior

I would expect that Turbopack would be able to resolve the path to the Skeleton plugin; however, it seems to be ignoring the exports in the package.json for Skeleton. The exact error is included below:

./tailwind.config.ts:1:1
Module not found: Can't resolve '@skeletonlabs/skeleton/plugin'
> 1 | import { skeleton } from "@skeletonlabs/skeleton/plugin";
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2 | import { cerberus } from "@skeletonlabs/skeleton/themes";
  3 | import type { Config } from "tailwindcss";
  4 |

https://nextjs.org/docs/messages/module-not-found

Provide environment information

Node.js v20.14.0

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP Fri Mar 29 23:14:13 UTC 2024
  Available memory (MB): 7896
  Available CPU cores: 12
Binaries:
  Node: 20.14.0
  npm: 10.8.1
  Yarn: 1.22.22
  pnpm: N/A
Relevant Packages:
  next: 15.0.0-rc.0 // Latest available version is detected (15.0.0-rc.0).
  eslint-config-next: 15.0.0-rc.0
  react: 19.0.0-rc-f994737d14-20240522
  react-dom: 19.0.0-rc-f994737d14-20240522
  typescript: 5.4.5
Next.js Config:
  output: N/A

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

Module Resolution, Turbopack

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

next dev (local)

Additional context

I tested the affected code with create-turbo@canary to create a reproduction for that repository, but the bug doesn't seem to appear in a standard turbo app (for reference, I tried the with-tailwind example, and it worked fine). I have also tried Bun, PNPM, and NPM suspecting a package manager issue (those have happened in the past), but still the issue persisted. Simply removing the --turbo flag from the next dev command causes everything to work as expected (you're free to try that yourself). I'm not sure what exactly is going on, but it seems that somewhere in the next dev pipeline, Turbo starts ignoring the exports field in some package.json files.

inceenes10 commented 4 months ago

same problem using path aliases

kdy1 commented 4 months ago

It fails with webpack, too.

The package is misconfigured. Please contact the authors of @skeletonlabs/skeleton instead.

image
./app/globals.css.webpack[javascript/auto]!=!./node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet[1].rules[12].oneOf[10].use[2]!./node_modules/next/dist/build/webpack/loaders/postcss-loader/src/index.js??ruleSet[1].rules[12].oneOf[10].use[3]!./app/globals.css
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './plugin' is not defined by "exports" in /Users/kdy1/projects/repro-next-66887/node_modules/@skeletonlabs/skeleton/package.json
github-actions[bot] commented 4 months ago

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.