-
-
Notifications
You must be signed in to change notification settings - Fork 868
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
Angular Universal error #997
Comments
Thanks so much for opening an issue! If you'd like me to give priority to answering your issue or would just like to support this project, then please consider supporting me on Patreon |
Hi, we have the same issue. |
@jeanft - I downgraded to angular-draggable-droppable@4.1.0 using a shrinkwrap file. The combination of that plus the latest version of angular-calendar is working smoothly for me. It appears as though the real issue is not with angular-calendar but with @mattlewis92's other package angular-draggable-droppable. |
One other note, I have not tested any of the in between versions of angular-draggable-droppable. There were a couple versions in between but I didn't try them as I knew 4.1.0 was working previously. |
The issue started because of this commit: mattlewis92/angular-draggable-droppable@78bdeb5 which adds the dom-autoscroller package, but unfortunately that package isn't compatible with universal. The only solution I can think of is to use the rollup replace plugin to manually tweak the bundle to be compatible with universal. If someone could hack around in node_modules and find a minimal find and replace solution in |
Thank you very much @PlexusMark for the reply. I never used shrinkwrap. I'll look at this now and try your solution. |
See below for an example. You'd add this as npm-shrinkwrap.json in the same folder location as your package.json. Once you add this, make sure your package.json references the same version of angular-calendar. In this example, I've got it using 0.27.2. Lastly, either delete your node_modules folder, or remove angular-calendar and angular-draggable-droppable from the node_modules folder, then do an npm install.
|
It works perfectly. Thank you @PlexusMark. Really appreciated. |
@mattlewis92 - Can be solved by using the rollup-plugin-insert and using I did a local POC and it appears to be working correctly now with version angular-calendar@0.27.8 and angular-draggable-droppable@4.3.0. |
PR created: |
I just cut |
I version bumped locally and its working smoothly for me. I am running universal and AOT locally. |
Hi @PlexusMark and @mattlewis92, I am getting the error with v0.27.9 and SSR. Do you have some hint how to solve it? Also the same error occurs for me with the latest version 0.27.11. |
@jovicazaric Can you make a repo on github with a minimal reproduction? Thanks! |
Hi @mattlewis92, here is a test repo with enabled SSR and installed angular-calendar package: Dev environment: This is an error: ReferenceError: window is not defined It looks like the error comes from DragAndDropModule. If it is required for calendar, are there some other settings needed for running SSR. Thank you. |
Ah, it's because of the post processing of the bundle done by
|
Hi @mattlewis92, thank you a lot. The fix works. I am able to render calendar with SSR. |
@mattlewis92 Thanks! The last solution worked for me! I have 0.27.13 version :) |
Hi @mattlewis92 After adding { extensions: ['.ts', '.js'], mainFields: ['main', 'module'] },
/var/www/html/angular8new/dist/server.js:350283 ReferenceError: window is not defined npm ERR! A complete log of this run can be found in: |
I still have the same issue even after putting { extensions: ['.ts', '.js'], mainFields: ['main', 'module'] }
This is the part of the code that throws the error:
Below is the error that I get:
|
@kimhonoridez, global['window'] = win; |
Hi, I changed the post processing of the bundle done by webpack.server.config.js by adding mainFields: ['main', 'module'] to the resolve property of webpack.server.config.js as proposed by @mattlewis92 but that raised another issue, same as the one that @anantksingh and @kimhonoridez got:
I am using:
And... after many many attempts and workarounds**, I could make it work just by using the code proposed by @anantksingh** in my server.ts (just after the imports section) Thanks a lot but I wonder if we are potentially hiding issues with SSR by using this "window-object-mocking" technique, what do you think? |
Hi @mattlewis92! "@angular/core": "^9.0.6", `diff --git a/webpack.server.config.js b/webpack.server.config.js
|
@anishchcenko you need to add these 2 lines to the top of the |
It works! |
Describe the bug
I am seeing an issue with running angular-calendar using Universal/SSR. The specific issue is one step lower with the angular-draggable-droppable package where it is failing to find a definition for window, which is to be expected on Universal.
Minimal reproduction of the problem with instructions
N/A Applies to Universal only, not sure that I can do a Stackblitz with universal.
Screenshots
`/Users/User/Projects/project/website/node_modules/angular-draggable-droppable/bundles/angular-draggable-droppable.umd.js:118
for (var i = 0, limit = prefix.length; i < limit && !window.requestAnimationFrame; ++i) {
^
ReferenceError: window is not defined
at /Users/User/Projects/project/website/node_modules/angular-draggable-droppable/bundles/angular-draggable-droppable.umd.js:118:57
at /Users/User/Projects/project/website/node_modules/angular-draggable-droppable/bundles/angular-draggable-droppable.umd.js:141:3
at createCommonjsModule (/Users/User/Projects/project/website/node_modules/angular-draggable-droppable/bundles/angular-draggable-droppable.umd.js:19:36)
at /Users/User/Projects/project/website/node_modules/angular-draggable-droppable/bundles/angular-draggable-droppable.umd.js:109:35
at /Users/User/Projects/project/website/node_modules/angular-draggable-droppable/bundles/angular-draggable-droppable.umd.js:2:82
at Object. (/Users/User/Projects/project/website/node_modules/angular-draggable-droppable/bundles/angular-draggable-droppable.umd.js:5:2)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)`
Versions
@angular/core
: 6.1.7angular-calendar
: 0.27.8The text was updated successfully, but these errors were encountered: