react-flagpack icon indicating copy to clipboard operation
react-flagpack copied to clipboard

Flagpack not loading into NextJS

Open daoneandonly opened this issue 3 years ago • 9 comments

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 the package.json also stops the project from crashing altogether, however the flag still doesn't render.

Logs

image

Related to issues #46, #45

daoneandonly avatar Sep 15 '21 13:09 daoneandonly

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

Titou325 avatar Oct 04 '21 22:10 Titou325

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.

tjablonski avatar Dec 09 '21 10:12 tjablonski

any update on this bug, the fix is simple

yotam707 avatar Jan 05 '22 13:01 yotam707

It should be a great addition. Many of us are waiting to implement it with NextJS.

vrushank avatar Jan 07 '22 12:01 vrushank

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 avatar Jan 07 '22 20:01 mbale

@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 🙆‍♂️.

donovanroubos avatar Jan 18 '22 10:01 donovanroubos

still on it ?

intensr avatar Apr 21 '22 10:04 intensr

Is there any timeline on when this will be resolved?

ethanmick avatar Oct 19 '22 23:10 ethanmick

Same error

digitaltim-de avatar Nov 18 '22 05:11 digitaltim-de