question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When serving es5 ngx-socket-io gives me error

See original GitHub issue

🐞 bug report

Is this a regression?

From what I remember it didn’t worked with angular 9 either

Description

.

I’m using an old IPad 2 for development and just upgraded to angular 10. I’m using ngx-socket-io but I’m trying to build the project using es5. I followed the guideline for building es5 from here

I notice that angular is using even in es5 the bundle fesm2015 of ngx-socket-io causing this unknown error. When running ng serve it says compiling ngx-socket-io : es2015 as esm2015 I needed to use old safari in order to get the debugger working, so finding the precise error is kind of painful. notice that basic app using ng new projectName is working on my ipad.

I use this command ng serve --aot --configuration es5 --host 192.168.XX.XX

this is my first GitHub Bug report please let me know if I’m doing wrong or at the wrong place

Thanks in advance

πŸ”¬ Minimal Reproduction

I wasn’t able to reproduce it on stackBlitz but basically you only have to install ngx-socket-io import it on your new project and make ng serve with host value for safari 9 –>

πŸ”₯ Exception or Error

Capture d’écran 2020-07-17 aΜ€ 13 28 30

🌍 Your Environment

Angular Version:




Safari 9
IOS 9.3.5
Angular 10.0.3

Anything else relevant?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
clydincommented, Jul 21, 2020

Angular CLI 10.0 will now down-level vendor files when targeting ES5 within the application’s TypeScript configuration. Vendor files were previously only down-leveled as a side effect of using differential loading which down-leveled the entire application as a post-processing step. In this particular case, the debug package contains ES2015 features within the code chosen by the webpack configuration (browser field in the package’s package.json). As a result, prior to Angular CLI 10.0, this package would not work on older browsers except when using differential loading. With Angular CLI 10.0, the package should now be usable even without using differential loading on older browsers. However, the package’s code contains ES2015 features (spread operators) that require helper functions to fully down-level. These helper functions need to be referenced (imported/required) within package’s code to work. Before the fix referenced in this issue, the file was assumed to be an ES module but it is actually a commonJS file (it has no require calls but it does assign to module.exports). As it was assumed to be an ES module, the down-leveling process was adding import statements to the file and not require calls. Finally, the presence of newly added import statements was in turn causing Webpack to assume that the file was an ES module file and, as a result, processing the file differently than it should. This different processing was what was breaking the package and causing the runtime error.

1reaction
petebacondarwincommented, Jul 17, 2020

It is normal for ngcc to process the ES2015 version of the library. The ES5 version of the application is created at the end of the build by downleveling the ES2015 version of the app. So the order of things is that your TS code is compiled by Angular/TypeScript, webpack bundles this with the imported 3rd party libraries into ES2015 formatted distributable files, these ES2015 files are downleveled to ES5.

Now I believe that your index.html should be setup to use the ES5 dist files on older browsers, and ES2015 otherwise.

Can you see if ES5 versions are being built if you run ng build --aot --configuration es5?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting connection issues | Socket.IO
Common errors: the server might not be reachable. Please make sure the Socket.IO server is actually reachable at the given URL.
Read more >
Internet Explorer 11, Angular 8 and SocketIO Compatibility
Just resolved the same issue by downgrading the socket.io-client package to version ~2.2.0 in package.json. Seems like since version 2.3Β ...
Read more >
ngx-socket-io - npm
The SocketIoModule provides now a configured Socket service that can be injected anywhere inside the AppModule . import { Injectable } from '@Β ......
Read more >
Angular CLI v10.1.0-next.2 Release - GitClear
When serving es5 ngx-socket-io gives me error Β· #18284 Β· build: update open to version 7.1.0 ... build(deps): bump websocket-extensions from 0.1.3 to...
Read more >
How To Create a Real-Time App with Socket.IO, Angular, and ...
How To Create a Real-Time App with Socket.IO, Angular, and Node.js Β· Step 1 β€” Setting Up the Project Directory and Creating the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found