question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

v1.21.0 breaks with next.js, or without graceful-fs upgrade

See original GitHub issue

Sadly, v1.21.0 seems to break babel-plugin-macros. If I pin resolve to v1.20.0, everything is fine. 2.0.0-next.3 also seems to be working. This is especially hard to debug, as its a transient dependency of many libs/plugins and a minor update. It took me quite a while to find it… 😃

Related stacktrace:

Uncaught     at Object.statSync (file:///~/next.js/examples/with-babel-macros/node_modules/.pnpm/next@12.0.0_react-dom@17.0.2+react@17.0.2/node_modules/next/dist/compiled/@vercel/nft/index.js:1:293416)
    at isDirectory (file:///~/next.js/examples/with-babel-macros/node_modules/.pnpm/resolve@1.21.0/node_modules/resolve/lib/sync.js:22:23)
    at loadNodeModulesSync (file:///~/next.js/examples/with-babel-macros/node_modules/.pnpm/resolve@1.21.0/node_modules/resolve/lib/sync.js:191:17)
    at Function.resolveSync [as sync] (file:///~/next.js/examples/with-babel-macros/node_modules/.pnpm/resolve@1.21.0/node_modules/resolve/lib/sync.js:98:17)
    at nodeResolvePath (file:///~/next.js/examples/with-babel-macros/node_modules/.pnpm/babel-plugin-macros@3.1.0/node_modules/babel-plugin-macros/dist/index.js:62:18)
    at applyMacros (file:///~/next.js/examples/with-babel-macros/node_modules/.pnpm/babel-plugin-macros@3.1.0/node_modules/babel-plugin-macros/dist/index.js:203:23)
    at ImportDeclaration (file:///~/next.js/examples/with-babel-macros/node_modules/.pnpm/babel-plugin-macros@3.1.0/node_modules/babel-plugin-macros/dist/index.js:110:28)
    at NodePath._call (file:///~/next.js/examples/with-babel-macros/node_modules/.pnpm/next@12.0.0_react-dom@17.0.2+react@17.0.2/node_modules/next/dist/compiled/babel/bundle.js:1890:292021)
    at NodePath.call (file:///~/next.js/examples/with-babel-macros/node_modules/.pnpm/next@12.0.0_react-dom@17.0.2+react@17.0.2/node_modules/next/dist/compiled/babel/bundle.js:1890:291845)
    at NodePath.visit (file:///~/next.js/examples/with-babel-macros/node_modules/.pnpm/next@12.0.0_react-dom@17.0.2+react@17.0.2/node_modules/next/dist/compiled/babel/bundle.js:1890:292796)
    at processResult (file:///~/next.js/examples/with-babel-macros/node_modules/.pnpm/next@12.0.0_react-dom@17.0.2+react@17.0.2/node_modules/next/dist/compiled/webpack/bundle5.js:53057:19)
    at <unknown> (file:///~/next.js/examples/with-babel-macros/node_modules/.pnpm/next@12.0.0_react-dom@17.0.2+react@17.0.2/node_modules/next/dist/compiled/webpack/bundle5.js:53159:5)
    at <unknown> (file:///~/next.js/examples/with-babel-macros/node_modules/.pnpm/next@12.0.0_react-dom@17.0.2+react@17.0.2/node_modules/next/dist/compiled/webpack/bundle5.js:138518:11)
    at <unknown> (file:///~/next.js/examples/with-babel-macros/node_modules/.pnpm/next@12.0.0_react-dom@17.0.2+react@17.0.2/node_modules/next/dist/compiled/webpack/bundle5.js:138370:18)
    at context.callback (file:///~/next.js/examples/with-babel-macros/node_modules/.pnpm/next@12.0.0_react-dom@17.0.2+react@17.0.2/node_modules/next/dist/compiled/webpack/bundle5.js:138243:13)
    at <unknown> (file:///~/next.js/examples/with-babel-macros/node_modules/.pnpm/next@12.0.0_react-dom@17.0.2+react@17.0.2/node_modules/next/dist/build/babel/loader/index.js:33:61)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:23 (12 by maintainers)

github_iconTop GitHub Comments

4reactions
xvvvyzcommented, Jan 6, 2022

@ljharb upgrading to next@12.0.8-canary.19 did indeed fix this issue for me.

I came across the error by using babel-plugin-inline-react-svg for reference.

3reactions
ljharbcommented, Jan 6, 2022

Great to hear. I’ll close this once v12.0.8 of next is published.

In summary:

  • v1.21 of resolve started using throwIfNoEntry with fs.statSync
  • graceful-fs had a bug with throwIfNoEntry, which was fixed in v4.2.9. (Using resolve v1.2andgraceful-fs` < 4.2.9 in combination is one way to trigger the bug)
  • next prior to v12.0.8 sadly bundles, transitively, a version of graceful-fs earlier than v4.2.9 (if they hadn’t bundled this, then users would have been able to fix it themselves. since @vercel/nft switched to not using graceful-fs to monkeypatch the environment, this won’t likely be a problem in the future)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Upgrade Guide - Next.js
Upgrade Guide. Upgrading from 12 to 13. To update to Next.js version 13, run the following command using your preferred package manager:
Read more >
Next.js 13 Upgrade Guide
Learn how to upgrade your Next.js application. ... reducing the combined complexity of these updates by breaking down your migration into smaller steps....
Read more >
Upgrading: Version 10 - Next.js beta docs
There were no breaking changes between versions 9 and 10. To upgrade to version 10, run the following command: npm install next@10 #...
Read more >
Blog - Next.js 13
js 13 (stable) lays the foundations to be dynamic without limits: app Directory (beta): Easier, faster, less client JS. Layouts; React Server ...
Read more >
Advanced Features: Next.js Compiler
js. We chose to build on SWC for a few reasons: Extensibility: SWC can be used as a Crate inside Next.js, without having ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found