Closed maktouch closed 4 years ago
Figured it out, it was a bad babel config =)
Wow thanks @maktouch, your repository finally lead me to a solution. My issue was fixed by replacing .babelrc
containing:
{
"presets": ["next/babel"],
"plugins": ["macros"]
}
with babel.config.js
containing:
module.exports = {
presets: [require.resolve('next/babel')],
plugins: [[require.resolve('babel-plugin-macros')]],
};
babel-plugin-macros
version: 2.7.0node
version: 10.16.3npm
(oryarn
) version: 1.16.0Relevant code or config
What you did:
When this is used inside NextJS, it works correctly.
When this is extracted as a package in the monorepo, imported and used, it doesn't, with error:
Reproduction repository:
https://github.com/maktouch/micro-frontends-poc
Problem description:
There's something fishy going on with the way Next handles this, because it works pretty much out of the box for CRA and Gatsby. The problem arose when I tried to use a component with Lingui, but it didn't work. I thought it somehow missed some Lingui magic but after investigating for the whole day, it seems like Macro + External package + Next doesn't work.
Suggested solution:
Could it be because of this module? https://github.com/martpie/next-transpile-modules.