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

Next.js: Allow multiple component in imports #3481

Closed
vitalijalbu opened this issue Oct 17, 2022 · 13 comments
Closed

Next.js: Allow multiple component in imports #3481

vitalijalbu opened this issue Oct 17, 2022 · 13 comments
Assignees
Labels
Status: Discussion Issue or pull request needs to be discussed by Core Team

Comments

@vitalijalbu
Copy link

vitalijalbu commented Oct 17, 2022

Describe the bug

When using Next.js and trying to import import { Button, InputText } from "primereact"; it fails with.

image

Works fine if you use tree shaking imports however like:

import { Button} from "primereact/button"
import { InputText } from "primereact/inputtext"

Reproducer

https://codesandbox.io/s/youthful-carlos-gckc2q?file=/pages/index.js

PrimeReact version

8.6.1

React version

18.x

Language

ALL

Build / Runtime

Next.js 12.3.1

@vitalijalbu vitalijalbu added Status: Discussion Issue or pull request needs to be discussed by Core Team Type: New Feature Issue contains a new feature or new component request labels Oct 17, 2022
@github-actions github-actions bot added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Oct 17, 2022
@melloware
Copy link
Member

You must have missed this pinned ticket: #3288

@melloware melloware added Resolution: Wontfix Issue will not be fixed due to technical limitations and removed Type: New Feature Issue contains a new feature or new component request Status: Discussion Issue or pull request needs to be discussed by Core Team Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Oct 17, 2022
@melloware melloware self-assigned this Oct 17, 2022
@melloware
Copy link
Member

You need to run yarn add quill chart.js

@vitalijalbu
Copy link
Author

You need to run yarn add quill chart.js

i did it, but gives me error (nextjs)

Schermata 2022-10-17 alle 17 12 08

@melloware
Copy link
Member

melloware commented Oct 17, 2022

that error has nothing to do with the above. You are missing an import. I thin kyou need to take a step back and build a simple example. You are trying to run before you have learned to walk

@melloware
Copy link
Member

Start simple with this PrimeReact starter for Next.JS: https://github.com/primefaces/primereact-examples/tree/main/nextjs-basic

@vitalijalbu
Copy link
Author

Start simple with this PrimeReact starter for Next.JS: https://github.com/primefaces/primereact-examples/tree/main/nextjs-basic

https://codesandbox.io/s/rough-firefly-84kwwi?file=/pages/index.js. here is an example, just made it... let me know pls what i'm missing.

@melloware melloware added Type: Bug Issue contains a defect related to a specific component. and removed Resolution: Wontfix Issue will not be fixed due to technical limitations labels Oct 17, 2022
@melloware melloware changed the title Allow multiple components import in React Next.js: Allow multiple components import in React Oct 17, 2022
@melloware melloware reopened this Oct 17, 2022
@github-actions github-actions bot added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Oct 17, 2022
@melloware
Copy link
Member

I re-opened your ticket and updated the description. Looks like this problem is specific to Next.JS as it works fine with Create React App. Your only solution right now is to use explicit components like..

import { Button} from "primereact/button"
import { InputText } from "primereact/inputtext"

@melloware melloware removed the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Oct 17, 2022
@melloware melloware assigned mertsincan and unassigned melloware Oct 17, 2022
@melloware melloware changed the title Next.js: Allow multiple components import in React Next.js: Allow multiple component in imports Oct 17, 2022
@vitalijalbu
Copy link
Author

I re-opened your ticket and updated the description. Looks like this problem is specific to Next.JS as it works fine with Create React App. Your only solution right now is to use explicit components like..

import { Button} from "primereact/button"
import { InputText } from "primereact/inputtext"

yes it seems like there's a bug. thanks anyway, pls update me when is fixed :D

@ulasturann
Copy link
Contributor

Hi @vitalijalbu,
It seems like you have just missed the _app.js file in your example.
Here is an example that forked from your first reproducer.

Please have a look at the link below;
https://codesandbox.io/s/muddy-bird-oz6fuo?file=/pages/index.js

@vitalijalbu
Copy link
Author

Start simple with this PrimeReact starter for Next.JS: https://github.com/primefaces/primereact-examples/tree/main/nextjs-basic

https://codesandbox.io/s/rough-firefly-84kwwi?file=/pages/index.js. here is an example, just made it... let me know pls what i'm missing.

@ulasturann pls see here, they told me it was an issue with the library, i want multiple imports {button, input, ...etc}

@ulasturann ulasturann added Status: Discussion Issue or pull request needs to be discussed by Core Team and removed Type: Bug Issue contains a defect related to a specific component. labels Oct 20, 2022
@ulasturann
Copy link
Contributor

Hi again @vitalijalbu,
As you mentioned, we are currently using tree-shaking which is why this is not an issue. We are discussing it but unfortunately, I can only recommend the correct use of the specified for now. We will let you know in case of any changes related to the issue.

Describe the bug

When using Next.js and trying to import import { Button, InputText } from "primereact"; it fails with.
.
.

Works fine if you use tree shaking imports however like:

import { Button} from "primereact/button"
import { InputText } from "primereact/inputtext"

.
.

@vitalijalbu
Copy link
Author

Hi again @vitalijalbu, As you mentioned, we are currently using tree-shaking which is why this is not an issue. We are discussing it but unfortunately, I can only recommend the correct use of the specified for now. We will let you know in case of any changes related to the issue.

Describe the bug

When using Next.js and trying to import import { Button, InputText } from "primereact"; it fails with.
.
.

Works fine if you use tree shaking imports however like:

import { Button} from "primereact/button"
import { InputText } from "primereact/inputtext"

.
.

yes but it's no a good idea, instead of having 1 row of import components, we'll have 10!
https://discord.com/channels/787967399105134612/787968635414118421/1031580421722484907

@melloware
Copy link
Member

@vitalijalbu that is purely syntax but by doing it the "tree shaking" way you actually are making a smaller more efficient deployment. Your way it has to bring in the entire primereact.js file instead of just the components you are using.

And your reason is because you want imports on one line??? That doesn't seem like a good tradeoff for performance.

@ulasturann ulasturann self-assigned this Oct 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Discussion Issue or pull request needs to be discussed by Core Team
Projects
None yet
Development

No branches or pull requests

4 participants