react-flagpack
react-flagpack copied to clipboard
Flagpack not loading into NextJS
Please check all that apply
- [x] functional bug
Current Behavior
Currently the project doesn't work with NextJS. It does work however with a create-react-app
.
Possible Solution
- A possible solution is adding a ESM file to the exports through rollup.
- Removing the
type: "module"
from thepackage.json
also stops the project from crashing altogether, however the flag still doesn't render.
Logs
Related to issues #46, #45
Hello!
It seems that this error is also affecting Gatsby, which does not provide any way to call require
from imported CommonJS modules.
In the meantime, I am using patch-package to replace "type": "module"
with "type": "commonjs"
in package.json
. I can then use the standard import syntax import Flag from 'react-flagpack'
.
I think this change could easily be implemented without breaking the current setup, until an ESM build is made available.
Have a nice day
Hello,
i have similar problem importing react-flagpack
with storybook, when i try to use Flag component in my Country component, it shows Unexpected error while loading ./components/Country/Country.stories.tsx: ReferenceError: require is not defined
in console. My component dissapear from storybook components list.
any update on this bug, the fix is simple
It should be a great addition. Many of us are waiting to implement it with NextJS.
https://github.com/mbale/react-flagpack
There's a nextjs branch if you cannot wait for the PR.
Tested with v12 and imported the esm build from dist directly
@mbale Is this fix also compatible with other React platforms (SB, CRA, Next JS, etc.). If yes, could you maybe create a PR for this fix? Would be awesome 🙆♂️.
still on it ?
Is there any timeline on when this will be resolved?
Same error