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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fluent "lib-commonjs" export from fabric "lib" #12464

Closed
itslooklike opened this issue Mar 29, 2020 · 9 comments
Closed

fluent "lib-commonjs" export from fabric "lib" #12464

itslooklike opened this issue Mar 29, 2020 · 9 comments

Comments

@itslooklike
Copy link

Hello 馃憢

i use import { PrimaryButton } from '@fluentui/react/lib-commonjs/Button'; in nextjs
and got error SyntaxError: Unexpected token 'export'

i open node_modules/@fluentui/react/lib-commonjs/Button.js and saw, what hi require office-ui-fabric-react/lib/Button (lib not lib-commonjs)

is it wrong export? (i check only PrimaryButton component, maybe this problem in another components too)

image

Environment Information

  • "@fluentui/react": "^7.105.5"

Priorities and help requested:

Are you willing to submit a PR to fix? (No)

Requested priority: (Normal)

@aneeshack4
Copy link
Contributor

@itslooklike
Copy link
Author

@aneeshack4 to be honest, I don't know which button I'm trying to use
I just want to use any button, and try example from readme.md and get error

https://github.com/microsoft/fluentui#integrating-in-your-project

image

@aneeshack4
Copy link
Contributor

aneeshack4 commented Mar 31, 2020

@itslooklike I believe that used to say: import { PrimaryButton } from 'office-ui-fabric-react/lib/Button';
This was changed recently. Try out ^ and lmk if it doesn't work.

@aneeshack4
Copy link
Contributor

@itslooklike Actually wait why don't use import { PrimaryButton } from '@fluentui/react/lib/Button'; - as in use lib instead of lib-common. I think that should work you - let me know.

@itslooklike
Copy link
Author

@aneeshack4 i need use lib-commonjs version of module, because i need SSR
i think problem is what lib-commonjs version module have wrong export
It export ESM module, but must export CommonJS

i create a codesanbox, if it can help https://codesandbox.io/s/fluent-cjcm4

@itslooklike
Copy link
Author

well, i solve my problem, by use import { PrimaryButton } from "@fluentui/react
so its wrong build process for common-js modules, or confusing documentation

@aneeshack4
Copy link
Contributor

@itslooklike Glad you were able to fix the problem. I'm not sure if the documentation stating the import { PrimaryButton } from '@fluentui/react/lib/Button'; is correct. I do know office-ui-fabric-react has been re-exported but maybe the lib part isn't correct. I believe @ecraig12345 recently made this change in PR #12378 - Elizabeth do you think this needs to be changed?

@ecraig12345
Copy link
Member

This is interesting--the checked in code using lib paths is correct, but I think we need to add a post-build step to @fluentui/react which converts lib imports in the commonjs build output to lib-commonjs. @kenotron added code for a step like this in the past, but I'm not sure if we ever enabled it.

@ecraig12345
Copy link
Member

This was fixed at some point in the past year by adding a postprocessing step. If anyone notices it break again, feel free to file a new issue.

@microsoft microsoft locked as resolved and limited conversation to collaborators Feb 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants