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

Can't transpile a babel macro project #33003

Closed
Kikobeats opened this issue Jan 4, 2022 · 14 comments · Fixed by #33048
Closed

Can't transpile a babel macro project #33003

Kikobeats opened this issue Jan 4, 2022 · 14 comments · Fixed by #33048
Labels
bug Issue was opened via the bug report template.

Comments

@Kikobeats
Copy link
Member

Run next info (available from version 12.0.8 and up)

next info is still not available, but I run npx envinfo --binaries --system:

  System:
    OS: macOS 12.0.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 76.88 MB / 32.00 GB
    Shell: 3.3.1 - /opt/homebrew/bin/fish
  Binaries:
    Node: 16.13.1 - ~/.local/share/nvm/v16.13.1/bin/node
    Yarn: 1.22.17 - /opt/homebrew/bin/yarn
    npm: 8.1.2 - ~/.local/share/nvm/v16.13.1/bin/npm

What version of Next.js are you using?

12.0.8-canary.16

What version of Node.js are you using?

v16.13.1

What browser are you using?

Chrome

What operating system are you using?

macOS

How are you deploying your application?

Vercel

Describe the Bug

CleanShot 2022-01-04 at 23 05 34@2x

For some reason, Next.js can't transpile .macro files.

The terminal is reporting something related to an uid, looks like an internal thing:

ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info  - Disabled SWC as replacement for Babel because of custom Babel configuration ".babelrc" https://nextjs.org/docs/messages/swc-disabled
event - compiled client and server successfully in 152 ms (144 modules)
wait  - compiling / (client and server)...
info  - Using external babel configuration from /Users/kikobeats/Downloads/with-babel-macros-app/.babelrc
error - ./pages/index.js
TypeError: Cannot read properties of undefined (reading 'uid')
(node:13611) [DEP_WEBPACK_MODULE_ISSUER] DeprecationWarning: Module.issuer: Use new ModuleGraph API
(Use `node --trace-deprecation ...` to show where the warning was created)
wait  - compiling /_error (client and server)...
error - ./pages/index.js
TypeError: Cannot read properties of undefined (reading 'uid')

I think what is happening is since the macro file is called *.macro.js, Next.js is wrongly interpreting it instead of leveraging to babel-plugin-macros for doing the job.

Expected Behavior

The macro should be interpreted by the babel plugin, not being interfered with by the Next.js internal compiler.

To Reproduce

just clone with-babel-macros

@Kikobeats Kikobeats added the bug Issue was opened via the bug report template. label Jan 4, 2022
@benbender

This comment has been minimized.

@benbender
Copy link
Contributor

Related stacktrace of the error:

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)

@benbender
Copy link
Contributor

benbender commented Jan 5, 2022

The problem originates from the resolve-package. Simply pin it to v1.20.0 to solve the error until a fix is released.

"resolutions": {
    "resolve": "1.20.0"
  }

Related bug there: browserify/resolve#264

@Kikobeats
Copy link
Member Author

@benbender is resolutions a yarn thing?

I added it to with-babel-macros package file, perform a npm install and the error is still there.

@benbender
Copy link
Contributor

@Kikobeats pnpm in this case. Yarn has a similar setting. I'm unsure about the latest npm.

@Kikobeats
Copy link
Member Author

It still doesn't work to me, but closing the issue since it isn't a Next.js thing.

@benbender
Copy link
Contributor

@Kikobeats did you pin it to v1.20.0? (There was a typo above which said v1.21.0, which is, in fact, the broken one)

@styfle styfle reopened this Jan 5, 2022
@kodiakhq kodiakhq bot closed this as completed in #33048 Jan 6, 2022
kodiakhq bot pushed a commit that referenced this issue Jan 6, 2022
This bumps `@vercel/nft` to the latest version and consequently bumps `graceful-fs` to the latest version.

- Fixes #33003
- Related to vercel/nft#258
- Related to browserify/resolve#264

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
@y1o1
Copy link

y1o1 commented Jan 6, 2022

I have exact same issue, and i found SWC is the cause.
Currently, v11.1.0 is the latest version w/o SWC and it can be built on my Docker container.

@benbender
Copy link
Contributor

@yoshi49535 not directly, see vercel/nft#257

@styfle
Copy link
Member

styfle commented Jan 6, 2022

Please try the latest release v12.0.8-canary.19 using yarn add next@canary or npm install next@canary to confirm that the issue is fixed, thanks!

@benbender
Copy link
Contributor

@styfle yes, I can confirm that the error is absent in canary 💯

@MaxEvan
Copy link

MaxEvan commented Jan 12, 2022

@styfle yes, I can confirm that the error is absent in canary 💯

Works I can confirm. Thanks so much, spent so much time on that!

@landsman
Copy link
Contributor

landsman commented Feb 1, 2022

@styfle Can I use this change with npm based project, next v11.1.3, override somehow that dependency?

natew pushed a commit to natew/next.js that referenced this issue Feb 16, 2022
This bumps `@vercel/nft` to the latest version and consequently bumps `graceful-fs` to the latest version.

- Fixes vercel#33003
- Related to vercel/nft#258
- Related to browserify/resolve#264

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2022

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

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants