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

EditorModule doesn't support SSR #8817

Closed
oxaoo opened this issue May 4, 2020 · 12 comments · Fixed by #14325
Closed

EditorModule doesn't support SSR #8817

oxaoo opened this issue May 4, 2020 · 12 comments · Fixed by #14325
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@oxaoo
Copy link

oxaoo commented May 4, 2020

I'm submitting a ...

[x] bug report
[ ] feature request
[ ] support request

Current behavior
The EditorModule doesn't support the server side rendering (SSR).

I have faced such a problem when have migrated from Angular 7 to Angular 9 (as well as PrimeNG 7 -> 9). There was a necessity to change package import for MessageService because service was moved from the primeng/components/common/messageservice package. I used the IDE hint to fix import problem and specified import {MessageService} from "primeng" that as it turned out to fetch all components from PrimeNG including EditorModule.
Specifying the appropriate package for component (like primeng/api for MessageService) solves this problem.
However, the problem with at least the EditorModule still remains.

Expected behavior
The EditorModule has to support the server side rendering (SSR).

Minimal reproduction of the problem with instructions

  1. Create a new Angular 9 project with PrimeNG 9
  2. Add EditorModule from the PrimeNG
  3. Add Angular Universal for SSR ng add @nguniversal/express-engine
  4. Start rendering app npm run dev:ssr
  5. After that there is following trace:
Compiled successfully.
E:\dev\primeng9-issue\example\dist\hello-world\server\main.js:259880
var elem = document.createElement('div');
           ^
ReferenceError: document is not defined
    at Object.<anonymous> (E:\dev\primeng9-issue\example\dist\hello-world\server\main.js:259880:12)
    at __webpack_require__ (E:\dev\primeng9-issue\example
\dist\hello-world\server\main.js:252255:30)
    at Object.<anonymous> (E:\dev\primeng9-issue\example\dist\hello-world\server\main.js:253249:1)
    at __webpack_require__ (E:\dev\primeng9-issue\example\dist\hello-world\server\main.js:252255:30)
    at Object.<anonym
ous> (E:\dev\primeng9-issue\example\dist\hello-world\server\main.js:257874:14)
    at __webpack_require__ (E:\dev\primeng9-issue\example\dist\hello-world\server\mai
n.js:252255:30)
    at Object.<anonymous> (E:\dev\primeng9-issue\example\dist\hello-world\server\main.js:262264:13)
    at __webpack_require__ (E:\dev\primeng9-issue\example\dist\hello-world\server\main.js:252255:30)
    at Object.<anonymous> (E:\dev\primeng9-issue\example\dist\hello-world\server\main.js:263776:18)
    at __webpack_require__ (E:\dev\primeng9-issue\example\dist
\hello-world\server\main.js:252255:30)

A server error has occurred.
node exited with 1 code.

After some investigation I've found that this code belongs to the quill on which Editor based.

Please tell us about your environment:

  • Angular version: 9.0.7
  • PrimeNG version: 9.0.6
  • Language: [TypeScript 3.7.5]

  • Other details:

Angular CLI: 9.0.7
Node: 12.0.0
OS: win32 x64

Angular: 9.0.7
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... platform-server, router
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.900.7
@angular-devkit/build-angular     0.900.7
@angular-devkit/build-optimizer   0.900.7
@angular-devkit/build-webpack     0.900.7
@angular-devkit/core              9.0.7
@angular-devkit/schematics        9.0.7
@angular/cdk                      9.2.2
@angular/material                 9.2.2
@ngtools/webpack                  9.0.7
@nguniversal/builders             9.1.0
@nguniversal/common               9.0.2
@nguniversal/express-engine       9.0.2
@schematics/angular               9.0.7
@schematics/update                0.900.7
rxjs                              6.5.5
typescript                        3.7.5
webpack                           4.41.2
@devxzero
Copy link

Same problem with ToastModule. https://www.primefaces.org/primeng/showcase/#/toast

"@angular/animations": "^10.0.5",
"@angular/cdk": "^10.1.0",
"@angular/common": "^10.0.5",
"@angular/compiler": "^10.0.5",
"@angular/core": "^10.0.5",
"@angular/forms": "^10.0.5",
"@angular/localize": "^10.0.5",
"@angular/material": "^10.1.0",
"@angular/platform-browser": "^10.0.5",
"@angular/platform-browser-dynamic": "^10.0.5",
"@angular/platform-server": "~10.0.5",
"@angular/router": "^10.0.5",
"@fullcalendar/core": "^5.1.0",
"@ng-bootstrap/ng-bootstrap": "^6.2.0",
"@nguniversal/express-engine": "^10.0.1",
"bootstrap": "^4.5.0",
"chart.js": "^2.9.3",
"express": "^4.15.2",
"primeicons": "^4.0.0",
"primeng": "^9.1.3",
"quill": "^1.3.7",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"zone.js": "~0.10.2"

@lennybakkalian
Copy link

i have the same problem

@yigitfindikli yigitfindikli added the Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add label Nov 23, 2020
@jdgamble555
Copy link

Same problem with p-icon

@mertsincan
Copy link
Member

Hi,

So sorry for the delayed response! Improvements have been made to many components recently, both in terms of performance and enhancement. Therefore, this improvement may have been developed in another issue ticket without realizing it. You can check this in the documentation. If there is no improvement on this, can you reopen the issue so we can include it in our roadmap?
Please don't forget to add your feedback as a comment after reopening the issue. These will be taken into account by us and will contribute to the development of this feature. Thanks a lot for your understanding!

Best Regards,

@Raul52
Copy link

Raul52 commented Jun 12, 2023

hello @mertsincan,

I cannot use primeng-editor with Angular SSR ( Angular 15 )

I get the following error:

./node_modules/quill/dist/quill.js:7661 var elem = document.createElement('div'); ^ ReferenceError: document is not defined at call (./node_modules/quill/dist/quill.js:7661:12) 

Can you please have a look?

@Talaat-Elesh
Copy link

Talaat-Elesh commented Jul 6, 2023

hello @mertsincan,

I cannot use primeng-editor with Angular SSR ( Angular 15 )

I get the following error:

./node_modules/quill/dist/quill.js:7661 var elem = document.createElement('div'); ^ ReferenceError: document is not defined at call (./node_modules/quill/dist/quill.js:7661:12) 

Can you please have a look?

Same exact issue as @Raul52
Please assist ASAP
Breaks locally and on live deploy
ONLY IF YOU HAVE ANGULAR UNIVERSAL (SSR)

@lqthang9900
Copy link

Same issue as @Raul52
It break Angular SSR :(

@LukeSamkharadze
Copy link

Any updates on this?

@nejat-njonjo
Copy link
Contributor

This issue has been bugging me a lot, so I created a custom module extending the default one, and I created a fix PR 14232. Hope it gets considered soon.

@cetincakiroglu cetincakiroglu added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working and removed Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add labels Dec 6, 2023
@cetincakiroglu cetincakiroglu reopened this Dec 6, 2023
@cetincakiroglu cetincakiroglu added this to the 17.0.0 milestone Dec 6, 2023
@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 Dec 6, 2023
cetincakiroglu added a commit that referenced this issue Dec 6, 2023
@cetincakiroglu
Copy link
Contributor

Fixed in #14232

@cetincakiroglu cetincakiroglu removed the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Dec 6, 2023
@khamui
Copy link

khamui commented Dec 9, 2023

I am still facing this issue.
Updated Angular to latest (v17.0.6) and primeNG to v17.0.0. I even inspected the component and it contains the latest check with platformId.

Particularly i am not sure about the part in angular.json, where it explicitly points to the quill files:

...
  "scripts": [
      "node_modules/quill/dist/quill.js"
   ],
...

Any ideas?

@aaron-cardenas
Copy link

aaron-cardenas commented Apr 19, 2024

Since you implemented this fix, the editor doesn't work inside of dialogs!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet