Replies: 1 comment 1 reply
-
Hey, u're absolutely right that the documentation around Let’s clarify a few things and suggest a working approach. What's happening The new This becomes especially tricky when dealing with packages like What can u do to make it work? For now, if u want to use
Example setup: // next.config.js
const path = require("path");
const nextConfig = {
webpack: (config) => {
config.resolve.alias["react-native$"] = "react-native-web";
config.resolve.alias["react-native-reanimated"] = path.resolve(
__dirname,
"node_modules/react-native-reanimated"
);
return config;
},
transpilePackages: ["react-native-reanimated"],
};
module.exports = nextConfig;
This forces the webpack alias to take effect, while still letting Next.js transpile the external package.
Notes:
transpilePackages only tells Next.js to process the package through Babel. It does not automatically apply webpack aliases.
If the module (like react-native-reanimated) relies on a specific alias or react-native path, that alias must be defined manually in webpack.resolve.alias.
If u’re importing JSX that fails to compile, that’s usually a sign that Babel didn’t process it — either because the alias didn’t work, or transpilePackages didn’t apply.
Proposal Feedback:
u're spot on — this could definitely use better integration or at least clearer documentation. It would be ideal if Next.js supported a merged config between aliasing and transpilation.
Until then, using a combination like above should work. If u’re up for contributing docs once u stabilize your setup, it would definitely help others in the same situation. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
Non-Goals
No response
Background
react-native / react-native-web
(which is working great using a webpack config for the alias), I wanted to addreact-native-reanimated
.next-transpile-modules
package -- I found the NextJS post saying to migrate to usingtranspilePackages
Proposal
transpilePackages
& apackage alias
.transpilePackages
or any other appropriate documentation. (As you can see, the documentation for that option is extremely limited today)Beta Was this translation helpful? Give feedback.
All reactions