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
π Your Environment
Angular Version:
Safari 9
IOS 9.3.5
Angular 10.0.3
Anything else relevant?
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (3 by maintainers)
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βspackage.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 tomodule.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.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
?