kentcdodds / babel-plugin-macros

🎣 Allows you to build simple compile-time libraries
https://npm.im/babel-plugin-macros
MIT License
2.62k stars 135 forks source link

webpack 5 build error #174

Closed mickdelaney closed 3 years ago

mickdelaney commented 3 years ago

Relevant code or config

What you did: I'm trying to setup react, typescript with relay using webpack 5. I've done this successfully with CRA, but wanted a more customizable config, and also am assessing if i can move to webpack 5. All goes well until i add relay, which relies on babel-plugin-macros.

NOTE: I've attempted to polyfill node for webpack 5.

https://github.com/mickdelaney/react-webpack-5-ts-relay/blob/master/webpack.config.js#L15

What happened:

the full build error is here: https://gist.github.com/mickdelaney/65cedc2e131a1e45edec18a4fb39c68d

Reproduction repository:

https://github.com/mickdelaney/react-webpack-5-ts-relay

Problem description:

Suggested solution:

I'm not an expert on these tools, so am considering just waiting a few months assuming things will stabilize with webpack 5 etc.

apuntovanini commented 3 years ago

Can confirm same issue with relay as well, but it came out when I added a dependency which also relies on babel-plugin-macros (twin.macro in particular)

EDIT: Probably it's "just" versions conflicting

├─ @rails/webpacker@npm:6.0.0-beta.7
│  └─ babel-plugin-macros@npm:3.1.0 (via npm:^3.0.1)
│
├─ babel-plugin-emotion@npm:10.2.2
│  └─ babel-plugin-macros@npm:2.8.0 (via npm:^2.0.0)
│
├─ babel-plugin-relay@npm:11.0.2
│  └─ babel-plugin-macros@npm:2.8.0 (via npm:^2.0.0)
│
├─ babel-plugin-relay@npm:11.0.2 [6f433]
│  └─ babel-plugin-macros@npm:2.8.0 (via npm:^2.0.0)
│
├─ twin.macro@npm:2.4.1
│  └─ babel-plugin-macros@npm:2.8.0 (via npm:^2.8.0)
│
└─ uidu@workspace:.
   └─ babel-plugin-macros@npm:3.1.0 (via npm:^3.1.0)
mickdelaney commented 3 years ago

fix, i've sort of figured out where i was going wrong.

a few things: https://github.com/mickdelaney/react-webpack-5-ts-relay/compare/fix-issue

happy to close this now.

conartist6 commented 3 years ago

Hmm, can you leave a quick summary of what you learned here in case it helps future users?

mickdelaney commented 3 years ago

Sure. Will do. Probably Monday/Tuesday. Friday Evening time here 😉

conartist6 commented 3 years ago

Closing this since it appears to be inactive. If anyone else encounters this problem bug @mickdelaney 😃