Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flagpack not loading into NextJS #47

Open
1 task done
daoneandonly opened this issue Sep 15, 2021 · 9 comments · May be fixed by #72
Open
1 task done

Flagpack not loading into NextJS #47

daoneandonly opened this issue Sep 15, 2021 · 9 comments · May be fixed by #72
Assignees
Labels
bug Something isn't working

Comments

@daoneandonly
Copy link
Contributor

daoneandonly commented Sep 15, 2021

Please check all that apply

  • 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

@Titou325
Copy link

Titou325 commented Oct 4, 2021

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

@donovanroubos donovanroubos added the bug Something isn't working label Oct 26, 2021
@tjablonski
Copy link

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.

@yotam707
Copy link

yotam707 commented Jan 5, 2022

any update on this bug, the fix is simple

@vrushank
Copy link

vrushank commented Jan 7, 2022

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

@mbale
Copy link

mbale commented Jan 7, 2022

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

@donovanroubos
Copy link
Member

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

@intensr
Copy link

intensr commented Apr 21, 2022

still on it ?

@ethanmick
Copy link

Is there any timeline on when this will be resolved?

@digitaltim-de
Copy link

Same error

@zoeyfrisart zoeyfrisart linked a pull request Apr 4, 2024 that will close this issue
@zoeyfrisart zoeyfrisart linked a pull request Apr 4, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants