JavaScriptServices icon indicating copy to clipboard operation
JavaScriptServices copied to clipboard

Update to Angular 4.0.0

Open ghost opened this issue 9 years ago β€’ 91 comments

Angular 4.0.0 has now been released http://angularjs.blogspot.com.au/2017/03/angular-400-now-available.html with some good improvements

ghost avatar Mar 25 '17 00:03 ghost

@SteveSandersonMS I've got this resolved. Would it be okay to submit a PR for the fix?

AmrineA avatar May 18 '17 15:05 AmrineA

@AmrineA I'm not getting any error with this, so I'm not sure what you'd be fixing. A PR might help to clarify what the issue is though, even if we don't apply it. Thanks for looking into this!

SteveSandersonMS avatar May 18 '17 15:05 SteveSandersonMS

@SteveSandersonMS It's related to using IE to run the application. I had the same issue with the template that @MarkPieszak had created and the solution was to add the necessary polyfills. I'll try to get a PR in soon.

AmrineA avatar May 18 '17 15:05 AmrineA

@SteveSandersonMS PR #953 has been created with the polyfills to fix this issue in IE.

AmrineA avatar May 19 '17 00:05 AmrineA

Yes those appear in lower IEs unless you have the correct polyfills from core-js. It'd be a good idea to include them (but leave them commented out, as not everyone needs lower than IE11, as it increases bundle size)

MarkPieszak avatar May 19 '17 02:05 MarkPieszak

@MarkPieszak I get the error in IE 11 on Windows 7. Not sure if it should work without​ them in that browser version or not.

AmrineA avatar May 19 '17 10:05 AmrineA

That's usually the evergreen polyfills that's usually needed, I think you're right! Too many combinations of things πŸ™ˆ Haha

MarkPieszak avatar May 19 '17 14:05 MarkPieszak

Yes those appear in lower IEs unless you have the correct polyfills from core-js. It'd be a good idea to include them (but leave them commented out, as not everyone needs lower than IE11, as it increases bundle size)

In this PR (https://github.com/aspnet/JavaScriptServices/pull/952) I am able to make my IE issue go away just by including:

import "core-js/client/shim";

at the top of boot-client.ts. Isn't core-js already included by Angular?

ADefWebserver avatar May 19 '17 15:05 ADefWebserver

It's not included, as trimming down package size is important, but adding that client/shim can get it to work yes! More details here: https://angular.io/docs/ts/latest/guide/browser-support.html

MarkPieszak avatar May 19 '17 15:05 MarkPieszak

I was able to add the client/shim reference and it worked. I also removed all references to core-js and it's still in my node_modules folder after running npm prune. Something must be referencing it and pulling it down as part of the template.

AmrineA avatar May 19 '17 15:05 AmrineA

Hello, I can't seem to figure this out (how to replace angular2-universal-polyfills/browser with core-js/shim polyfills)? I try to reference core-js/shim in the boot-client.ts but it doesn't recognize it and i find that my core-js folder doesn't have a shim sub-directory. When I try to install lates of core-js it says it's dependent on zone.js but I have the correct zone.js. Please let me know if and how you resolved these things to upgrade to Angular 4. I get the error "reflect-metadata shim is required when using class decorators" when running.

My boot-client.ts file is as follows: mport { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { AppModule } from './app/app.module'; import "reflect-metadata"; import 'bootstrap'; import { enableProdMode } from '@angular/core';

import "core-js/es6"; enableProdMode(); // Enable either Hot Module Reloading or production mode

// Boot the application, either now or when the DOM content is loaded const platform = platformBrowserDynamic(); const bootApplication = () => { platform.bootstrapModule(AppModule); }; if (document.readyState === 'complete') { bootApplication(); } else { document.addEventListener('DOMContentLoaded', bootApplication); }

Thank you, Colleen

cbcolleenb avatar Sep 25 '17 18:09 cbcolleenb

@cbcolleenb I use a separate polyfills.ts file with the following contents.

/** IE9, IE10 and IE11 requires all of the following polyfills. **/
import 'core-js/es6/symbol';
import 'core-js/es6/object';
import 'core-js/es6/function';
import 'core-js/es6/parse-int';
import 'core-js/es6/parse-float';
import 'core-js/es6/number';
import 'core-js/es6/math';
import 'core-js/es6/string';
import 'core-js/es6/date';
import 'core-js/es6/array';
import 'core-js/es6/regexp';
import 'core-js/es6/map';
import 'core-js/es6/set';

/** Evergreen browsers require these. **/
import 'core-js/es6/reflect';
import 'core-js/es7/reflect';

import 'zone.js';

I then import that at the very top of the boot-client.ts. I'm wondering if perhaps the order of the imports is causing you issues. Also, what do you have in your webpack.config.vendor.js file?

AmrineA avatar Sep 25 '17 19:09 AmrineA

Hi Adam, thanks for the quick response...my webpack.config.vendor.js file has the following:

var isDevBuild = process.argv.indexOf('--env.prod') < 0; var path = require('path'); var webpack = require('webpack'); var ExtractTextPlugin = require('extract-text-webpack-plugin'); var extractCSS = new ExtractTextPlugin('vendor.css');

module.exports = { node: { fs: 'empty' }, resolve: { extensions: ['*', '.ts', '.js'] }, module: { loaders: [ { test: /.(png|woff|woff2|eot|ttf|svg)(?|$)/, loader: 'url-loader?limit=100000' }, { test: /.css(?|$)/, loader: extractCSS.extract(['css-loader']) } ] }, entry: { vendor: [ 'reflect-metadata', 'rxjs', 'zone.js', '@angular/common', '@angular/compiler', '@angular/core', '@angular/forms', '@angular/http', '@angular/platform-browser', '@angular/platform-browser-dynamic', '@angular/router', 'systemjs', "acorn" ]

},
output: {
    path: path.join(__dirname, 'wwwroot', 'dist'),
    filename: '[name].js',
    library: '[name]_[hash]',
},
plugins: [
    extractCSS,
    new webpack.ProvidePlugin({
        $: 'jquery', jQuery: 'jquery'
    }), // Maps these identifiers to the jQuery package (because

Bootstrap expects it to be a global variable) //new webpack.optimize.OccurrenceOrderPlugin(), new webpack.DllPlugin({ path: path.join(__dirname, 'wwwroot', 'dist', '[name]-manifest.json'), name: '[name]_[hash]' }) ].concat(isDevBuild ? [] : [ new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } }) ]) };

I'm going to try your polyfill.ts . Thanks! Colleen

On Mon, Sep 25, 2017 at 2:33 PM, Adam Amrine [email protected] wrote:

@cbcolleenb https://github.com/cbcolleenb I use a separate polyfills.ts file with the following contents.

/** IE9, IE10 and IE11 requires all of the following polyfills. **/ import 'core-js/es6/symbol'; import 'core-js/es6/object'; import 'core-js/es6/function'; import 'core-js/es6/parse-int'; import 'core-js/es6/parse-float'; import 'core-js/es6/number'; import 'core-js/es6/math'; import 'core-js/es6/string'; import 'core-js/es6/date'; import 'core-js/es6/array'; import 'core-js/es6/regexp'; import 'core-js/es6/map'; import 'core-js/es6/set';

/** Evergreen browsers require these. **/ import 'core-js/es6/reflect'; import 'core-js/es7/reflect';

import 'zone.js';

I then import that at the very top of the boot-client.ts. I'm wondering if perhaps the order of the imports is causing you issues. Also, what do you have in your webpack.config.vendor.js file?

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aspnet/JavaScriptServices/issues/800#issuecomment-331987868, or mute the thread https://github.com/notifications/unsubscribe-auth/AS0dkto5sqkW14QMCDFg4K-N92FmDcYuks5sl__-gaJpZM4Mo5ff .

cbcolleenb avatar Sep 25 '17 19:09 cbcolleenb

also, this is my tsconfig.json:

{ "compilerOptions": { "emitDecoratorMetadata": true, "experimentalDecorators": true, "lib": [ "es6", "dom" ], "module": "es2015", "moduleResolution": "node", "noImplicitAny": false, "sourceMap": true, "suppressImplicitAnyIndexErrors": true, "target": "es5" }, "types": [ "node", "core-js" ], "exclude": [ "node_modules/*" ], "atom": { "rewriteTsconfig": false } }

and package.json:

{ "name": "Angular2Spa", "version": "0.0.0", "license": "UNLICENSED", "dependencies": { "@angular/common": "^4.4.3", "@angular/compiler": "^4.4.3", "@angular/core": "^4.4.3", "@angular/forms": "^4.4.3", "@angular/http": "^4.4.3", "@angular/platform-browser": "^4.4.3", "@angular/platform-browser-dynamic": "^4.4.3", "@angular/platform-server": "4.4.3", "@angular/router": "^4.4.3", "@angular/animations": "^4.4.3", "acorn": "^0.8.0", "core-js": "^2.5.1", "enhanced-resolve": "^3.0.2", "extract-text-webpack-plugin": "^3.0.0", "npm": "^5.0.3", "systemjs": "^0.19.47", "uglify-js": "^2.8.29", "babel-loader": "^7.1.1", "babel-core": "6.26.0", "file-loader": "^0.11.2", "postcss-loader": "^2.0.6", "style-loader": "^0.18.2", "webpack": "^3.2.0", "webpack-node-externals": "1.6.0", "webpack-merge": "4.1.0", "ts-loader": "2.3.7", "raw": "0.1.4", "to-string": "0.2.0", "bootstrap": "3.3.7", "css-loader": "0.28.7", "raw-loader": "0.5.1", "jquery": "3.2.1", "zone.js": "^0.8.17", "reflect-metadata": "0.1.10", "@progress/telerik-angular-report-viewer": "2.17.913" }, "devDependencies": { "@angular/compiler-cli": "4.4.3", "rxjs": "^5.2.0", "@types/node": "^6.0.60", "concurrently": "^3.1.0", "lite-server": "^2.3.0", "typescript": "^2.2.2" } } thanks, Colleen

On Mon, Sep 25, 2017 at 2:40 PM, Colleen [email protected] wrote:

Hi Adam, thanks for the quick response...my webpack.config.vendor.js file has the following:

var isDevBuild = process.argv.indexOf('--env.prod') < 0; var path = require('path'); var webpack = require('webpack'); var ExtractTextPlugin = require('extract-text-webpack-plugin'); var extractCSS = new ExtractTextPlugin('vendor.css');

module.exports = { node: { fs: 'empty' }, resolve: { extensions: ['*', '.ts', '.js'] }, module: { loaders: [ { test: /.(png|woff|woff2|eot|ttf|svg)(?|$)/, loader: 'url-loader?limit=100000' }, { test: /.css(?|$)/, loader: extractCSS.extract(['css-loader']) } ] }, entry: { vendor: [ 'reflect-metadata', 'rxjs', 'zone.js', '@angular/common', '@angular/compiler', '@angular/core', '@angular/forms', '@angular/http', '@angular/platform-browser', '@angular/platform-browser-dynamic', '@angular/router', 'systemjs', "acorn" ]

},
output: {
    path: path.join(__dirname, 'wwwroot', 'dist'),
    filename: '[name].js',
    library: '[name]_[hash]',
},
plugins: [
    extractCSS,
    new webpack.ProvidePlugin({
        $: 'jquery', jQuery: 'jquery'
    }), // Maps these identifiers to the jQuery package (because

Bootstrap expects it to be a global variable) //new webpack.optimize.OccurrenceOrderPlugin(), new webpack.DllPlugin({ path: path.join(__dirname, 'wwwroot', 'dist', '[name]-manifest.json'), name: '[name]_[hash]' }) ].concat(isDevBuild ? [] : [ new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } }) ]) };

I'm going to try your polyfill.ts . Thanks! Colleen

On Mon, Sep 25, 2017 at 2:33 PM, Adam Amrine [email protected] wrote:

@cbcolleenb https://github.com/cbcolleenb I use a separate polyfills.ts file with the following contents.

/** IE9, IE10 and IE11 requires all of the following polyfills. **/ import 'core-js/es6/symbol'; import 'core-js/es6/object'; import 'core-js/es6/function'; import 'core-js/es6/parse-int'; import 'core-js/es6/parse-float'; import 'core-js/es6/number'; import 'core-js/es6/math'; import 'core-js/es6/string'; import 'core-js/es6/date'; import 'core-js/es6/array'; import 'core-js/es6/regexp'; import 'core-js/es6/map'; import 'core-js/es6/set';

/** Evergreen browsers require these. **/ import 'core-js/es6/reflect'; import 'core-js/es7/reflect';

import 'zone.js';

I then import that at the very top of the boot-client.ts. I'm wondering if perhaps the order of the imports is causing you issues. Also, what do you have in your webpack.config.vendor.js file?

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aspnet/JavaScriptServices/issues/800#issuecomment-331987868, or mute the thread https://github.com/notifications/unsubscribe-auth/AS0dkto5sqkW14QMCDFg4K-N92FmDcYuks5sl__-gaJpZM4Mo5ff .

cbcolleenb avatar Sep 25 '17 19:09 cbcolleenb

@cbcolleenb Try the polyfills.ts first and see if that works for you.

AmrineA avatar Sep 25 '17 19:09 AmrineA

@cbcolleenb Take a look at how I implemented it here: https://github.com/emonney/QuickApp/blob/master/src/QuickApp/ClientApp/boot.browser.ts Using core.js sim. The project is based off this repo.

emonney avatar Sep 25 '17 19:09 emonney

Hi, after using polyfills.ts and removing the other references I had, I got a new error: "Uncaught TypeError: n.replace is not a function at Ie (vendor.js?v=cF-oRSzI7zKtOJYCqo4-VM3BFrYBGvp2TIrRTJXoo80:453) at vendor.js?v=cF-oRSzI7zKtOJYCqo4-VM3BFrYBGvp2TIrRTJXoo80:551 at Array.map () at t.normalizeStylesheet (vendor.js?v=cF-oRSzI7zKtOJYCqo4-VM3BFrYBGvp2TIrRTJXoo80:551) at t.normalizeLoadedTemplate (vendor.js?v=cF-oRSzI7zKtOJYCqo4-VM3BFrYBGvp2TIrRTJXoo80:551) at vendor.js?v=cF-oRSzI7zKtOJYCqo4-VM3BFrYBGvp2TIrRTJXoo80:551 at Object.then (vendor.js?v=cF-oRSzI7zKtOJYCqo4-VM3BFrYBGvp2TIrRTJXoo80:523) at t.normalizeTemplateOnly (vendor.js?v=cF-oRSzI7zKtOJYCqo4-VM3BFrYBGvp2TIrRTJXoo80:551) at t.normalizeTemplate (vendor.js?v=cF-oRSzI7zKtOJYCqo4-VM3BFrYBGvp2TIrRTJXoo80:551) at t.loadDirectiveMetadata (vendor.js?v=cF-oRSzI7zKtOJYCqo4-VM3BFrYBGvp2TIrRTJXoo80:572)

On Mon, Sep 25, 2017 at 2:50 PM, Adam Amrine [email protected] wrote:

@cbcolleenb https://github.com/cbcolleenb Try the polyfills.ts first and see if that works for you.

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aspnet/JavaScriptServices/issues/800#issuecomment-331992445, or mute the thread https://github.com/notifications/unsubscribe-auth/AS0dkkoiAWXAFJLzJLpu3y7y3-1m6sdfks5smAQcgaJpZM4Mo5ff .

cbcolleenb avatar Sep 25 '17 19:09 cbcolleenb

Hi, I looked at your code.. I had tried import 'core-js/client/shim'; before, but my version of core-js must not have shim as i couldn't find a shim sub-directory. Thanks, Colleen

On Mon, Sep 25, 2017 at 2:51 PM, Ebenezer Monney [email protected] wrote:

Take a look at how I implemented it here: https://github.com/emonney/ QuickApp/blob/master/src/QuickApp/ClientApp/boot.browser.ts Using core.js sim. The project is based off this repo.

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aspnet/JavaScriptServices/issues/800#issuecomment-331992706, or mute the thread https://github.com/notifications/unsubscribe-auth/AS0dkp0FMEwP5ZmDp51bMWAiPEoGGUkzks5smARPgaJpZM4Mo5ff .

cbcolleenb avatar Sep 25 '17 20:09 cbcolleenb

Have you rebuilt your vendor.js file recently?

On Mon, Sep 25, 2017 at 4:02 PM, Colleen [email protected] wrote:

Hi, I looked at your code.. I had tried import 'core-js/client/shim'; before, but my version of core-js must not have shim as i couldn't find a shim sub-directory. Thanks, Colleen

On Mon, Sep 25, 2017 at 2:51 PM, Ebenezer Monney <[email protected]

wrote:

Take a look at how I implemented it here: https://github.com/emonney/ QuickApp/blob/master/src/QuickApp/ClientApp/boot.browser.ts Using core.js sim. The project is based off this repo.

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <https://github.com/aspnet/JavaScriptServices/issues/800# issuecomment-331992706>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ AS0dkp0FMEwP5ZmDp51bMWAiPEoGGUkzks5smARPgaJpZM4Mo5ff>

.

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aspnet/JavaScriptServices/issues/800#issuecomment-331995634, or mute the thread https://github.com/notifications/unsubscribe-auth/AGDtPf8TvDoRhEX64XEb3ZaTJoxz_9nmks5smAbrgaJpZM4Mo5ff .

AmrineA avatar Sep 25 '17 20:09 AmrineA

it seems to build when I publish it.. is there an explicit way to re-build vendor?

On Mon, Sep 25, 2017 at 3:06 PM, Adam Amrine [email protected] wrote:

Have you rebuilt your vendor.js file recently?

On Mon, Sep 25, 2017 at 4:02 PM, Colleen [email protected] wrote:

Hi, I looked at your code.. I had tried import 'core-js/client/shim'; before, but my version of core-js must not have shim as i couldn't find a shim sub-directory. Thanks, Colleen

On Mon, Sep 25, 2017 at 2:51 PM, Ebenezer Monney < [email protected]

wrote:

Take a look at how I implemented it here: https://github.com/emonney/ QuickApp/blob/master/src/QuickApp/ClientApp/boot.browser.ts Using core.js sim. The project is based off this repo.

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <https://github.com/aspnet/JavaScriptServices/issues/800# issuecomment-331992706>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ AS0dkp0FMEwP5ZmDp51bMWAiPEoGGUkzks5smARPgaJpZM4Mo5ff>

.

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <https://github.com/aspnet/JavaScriptServices/issues/800# issuecomment-331995634>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ AGDtPf8TvDoRhEX64XEb3ZaTJoxz_9nmks5smAbrgaJpZM4Mo5ff>

.

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aspnet/JavaScriptServices/issues/800#issuecomment-331996501, or mute the thread https://github.com/notifications/unsubscribe-auth/AS0dkuICvkAcWJ2mfEjgjQJhAV2lpputks5smAesgaJpZM4Mo5ff .

cbcolleenb avatar Sep 25 '17 20:09 cbcolleenb