By default Angular -CLI Project Fails in Safari is strict culprit mode?

I installed the latest version of angular-cli and created a completely new project (my new application). This creates an always stylish β€œWelcome to the app” with the Angular logo and links to the Tour of Heroes, CLI Documentation and Angular Blog. I can accomplish this and access it locally on my Windows machine using Chrome and Firefox.

If this is strange when I try to access the same locally hosted application through Browserstack. When I hit it with a Mac running Safari 11, everything worked as expected.

However, when I try to access through a Mac device (such as an iPad) that uses Safari 10+, the application does not load and I get an error message: "SyntaxError: Unexpected keyword" const. Const const declarations are not supported in strict mode " . The error message is bound to a location in my version of vendor.bundle.js (in eval).

From my reading, it seems that older versions of Safari do not work with consts in strict mode. But I hope there is a workaround.

How do others deal with this? I'm not an angular-cli expert, so if there is an obvious solution, my apologies for not seeing it.

Any help would be greatly appreciated.

+5
source share
2 answers

I have the same problem. There seems to be a problem in webpack-dev-server (used under the hood @ angular / cli) that uses ES6 features and doesn't translate.

This is only a problem in older versions of Safari, but updating Safari is not a solution if you want to test older versions of Safari.

A temporary solution is to use an older version for webpack-dev-server by installing it and manually copying it to the local @ angular / cli directory:

 yarn add webpack-dev-server@2.7.1 --dev cp -R ./node_modules/webpack-dev-server ./node_modules/@angular/cli/node_modules/ ./node_modules/.bin/ng serve 
+4
source

ES6's capabilities for newer versions of the dev server call this, but more specifically, a live reboot function.

If you pass the --no-live-reload flag, you can test older devices without having to downgrade anything.

For example: ng serve --no-live-reload

+1
source

Source: https://habr.com/ru/post/1273156/


All Articles