Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

Update to Angular 4.0.0 #800

Closed
Closed

Description

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

Activity

  1. MarkPieszak commented on Mar 25, 2017

    @MarkPieszak
    Contributor

    Still a few things to work out in the integration, but here's what I have so far with .NET and Angular 4. I've started work in this repo (https://github.com/MarkPieszak/aspnetcore-angular2-universal) for now, but imagine it'll get into here soon enough

  2. MarkPieszak commented on Mar 25, 2017

    @MarkPieszak
    Contributor

    Yeah it's quite a bit more, also starting the process differently (now in the Controller) so that we can give .NET the other essential SEO data.

    Of course, if you don't care about server rendering, you can just shut it off and update to 4.0 real easily :)

  3. peterdobson commented on Mar 25, 2017

    @peterdobson

    Fantastic! Just had to change the port number in fetchdata.components.ts from http://localhost:5000/api/test/users to http://localhost:1780/api/test/users to get the fetch-data sample working.

  4. MarkPieszak commented on Mar 25, 2017

    @MarkPieszak
    Contributor

    Yes so that eventually that'll be set dynamically from the server wth DI, going into Angular, just one of the improvements needed!
    URLs must be absolute on the server, previously we patched them for you in Universal.

  5. skorunka commented on Mar 25, 2017

    @skorunka

    After upgrading to Ang4 i get this error hile runnign webpack on webpack.config file:

    ERROR in [at-loader] ./node_modules/angular2-universal/node_modules/angular2-platform-node/node-platform.d.ts:1:10
        TS2305: Module '"C:/Projects/EYC/Solutions/Anticipate/src/Eyc.Solutions.Anticipate.Ui.Web.2/node_modules/@angular/platform-browser/platform-browser"' has no exported member 'AnimationDriver'.
    

    Any idea? Than kyou.

  6. MarkPieszak commented on Mar 25, 2017

    @MarkPieszak
    Contributor

    You actually can't just update the current project here to Angular4 my apologies. It takes re shifting and removing a lot a lot of things, pull down that branch I pointed to @skorunka and try to port your app to it.

    Honestly though I'd suggest waiting a little bit until it's more cleaned up!

  7. skorunka commented on Mar 27, 2017

    @skorunka

    @MarkPieszak No worries, I understand. Thank you for advice, i will give it a try.

  8. seven1986 commented on Mar 28, 2017

    @seven1986

    AOT

    @starquake , sorry.
    AOT = ahead-of-time https://angular.cn/docs/ts/latest/guide/glossary.html
    We all expect officially asp net core angular upgrade to 4.0!

  9. starquake commented on Mar 28, 2017

    @starquake

    @seven1986 I'm sorry, what does 'AOT' mean?

  10. michelebombardi commented on Mar 28, 2017

    @michelebombardi

    @MarkPieszak Will you let us know here when you've done?

  11. ns8482e commented on Mar 28, 2017

    @ns8482e

    @MarkPieszak For angular 4 branch you pointed is still using es6-shim. Is there any plan to update it to core-js?

  12. MarkPieszak commented on Mar 28, 2017

    @MarkPieszak
    Contributor

    Sure, I'll ping everyone when it's all finished. @bm-software
    Yes there's a lot that needs to be updated along with core-js, such as AoT etc.

    For now that branch is bare bones but sometime in the next few days I'm hoping I can find a good bunch of hours where I can focus on it and get it into Masters with everyone fixed up in it.

  13. skorunka commented on Mar 29, 2017

    @skorunka

    @MarkPieszak You are our hero!

  14. 62 remaining items

  15. cbcolleenb commented on Sep 25, 2017

    @cbcolleenb
  16. cbcolleenb commented on Sep 25, 2017

    @cbcolleenb
  17. AmrineA commented on Sep 25, 2017

    @AmrineA
  18. cbcolleenb commented on Sep 25, 2017

    @cbcolleenb
  19. AmrineA commented on Sep 25, 2017

    @AmrineA
  20. cbcolleenb commented on Sep 25, 2017

    @cbcolleenb
  21. AmrineA commented on Sep 25, 2017

    @AmrineA

    I'm not sure if this helps, but here is my package.json. I wouldn't copy it verbatim or you'll get stuff you don't need and remove things you do.

    {
      "name": "appname",
      "version": "1.0.0",
      "dependencies": {
        "@angular/animations": "^4.0.0",
        "@angular/common": "^4.0.0",
        "@angular/compiler": "^4.0.0",
        "@angular/core": "^4.0.0",
        "@angular/forms": "^4.0.0",
        "@angular/http": "^4.0.0",
        "@angular/platform-browser": "^4.0.0",
        "@angular/platform-browser-dynamic": "^4.0.0",
        "@angular/platform-server": "^4.0.0",
        "@angular/router": "^4.0.0",
        "@types/node": "^7.0.12",
        "angular2-template-loader": "^0.6.2",
        "aspnet-webpack": "^1.0.17",
        "awesome-typescript-loader": "^3.0.0",
        "core-js": "^2.4.1",
        "css": "^2.2.1",
        "css-loader": "^0.28.0",
        "es6-shim": "^0.35.3",
        "es6-promise": "^4.1.0",
        "event-source-polyfill": "^0.0.9",
        "expose-loader": "^0.7.3",
        "extract-text-webpack-plugin": "^2.1.0",
        "file-loader": "^0.11.1",
        "html-loader": "^0.4.5",
        "json-loader": "^0.5.4",
        "preboot": "^4.5.2",
        "raw-loader": "^0.5.1",
        "rxjs": "^5.3.0",
        "style-loader": "^0.16.1",
        "to-string-loader": "^1.1.5",
        "typescript": "^2.2.2",
        "url-loader": "^0.5.8",
        "webpack": "^2.3.3",
        "webpack-hot-middleware": "^2.18.0",
        "webpack-merge": "^4.1.0",
        "zone.js": "^0.8.5",
        "font-awesome": "^4.7.0",
        "ionicons": "^3.0.0",
        "admin-lte": "^2.3.11"
      }
    }
    
    

    Here is my webpack.config.vendor.js:

    const path = require('path');
    const webpack = require('webpack');
    const ExtractTextPlugin = require('extract-text-webpack-plugin');
    const merge = require('webpack-merge');
    
    module.exports = (env) => {
        const extractCSS = new ExtractTextPlugin('vendor.css');
        const isDevBuild = !(env && env.prod);
        const sharedConfig = {
            stats: { modules: false },
            resolve: { extensions: ['.js'] },
            module: {
                rules: [
                    { test: /\.(jpg|png|woff|woff2|eot|ttf|svg)(\?|$)/, use: 'url-loader?limit=100000' }
                ]
            },
            entry: {
                vendor: [
                    '@angular/common',
                    '@angular/compiler',
                    '@angular/core',
                    '@angular/forms',
                    '@angular/http',
                    '@angular/platform-browser',
                    '@angular/platform-browser-dynamic',
                    '@angular/router',
                    '@angular/platform-server',
                    'admin-lte/bootstrap/css/bootstrap.css',
                    'admin-lte/dist/css/AdminLTE.css',
                    'admin-lte/dist/css/skins/skin-black.css',
                    'core-js',
                    'es6-shim',
                    'es6-promise',
                    'event-source-polyfill',
                    'font-awesome/css/font-awesome.css',
                    'ionicons/dist/css/ionicons.css',
                    //'jquery',
                    'zone.js',
                ]
            },
            output: {
                publicPath: '/dist/',
                filename: '[name].js',
                library: '[name]_[hash]'
            },
            plugins: [
                //new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery' }), // Maps these identifiers to the jQuery package (because Bootstrap expects it to be a global variable)
                new webpack.ContextReplacementPlugin(/angular(\\|\/)core(\\|\/)@angular/, path.join(__dirname, './ClientApp')),
                new webpack.IgnorePlugin(/^vertx$/) // Workaround for https://github.com/stefanpenner/es6-promise/issues/100
            ]
        };
    
        const clientBundleConfig = merge(sharedConfig, {
            output: { path: path.join(__dirname, 'wwwroot', 'dist') },
            module: {
                rules: [
                    { test: /\.css(\?|$)/, use: extractCSS.extract({ use: 'css-loader' }) }
                ]
            },
            plugins: [
                extractCSS,
                new webpack.DllPlugin({
                    path: path.join(__dirname, 'wwwroot', 'dist', '[name]-manifest.json'),
                    name: '[name]_[hash]'
                })
            ].concat(isDevBuild ? [] : [
                new webpack.optimize.UglifyJsPlugin()
            ])
        });
    
        return [clientBundleConfig];
    }
    

    Is there a specific browser you're using? Have you tried other browsers?

  22. cbcolleenb commented on Sep 25, 2017

    @cbcolleenb
  23. cbcolleenb commented on Sep 25, 2017

    @cbcolleenb
  24. k-krupka commented on Sep 25, 2017

    @k-krupka
  25. cbcolleenb commented on Sep 26, 2017

    @cbcolleenb
  26. AmrineA commented on Sep 26, 2017

    @AmrineA

    tsconfig.json:

    {
      "compilerOptions": {
        "moduleResolution": "node",
        "target": "es5",
        "sourceMap": true,
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true,
        "skipDefaultLibCheck": true,
        "lib": [ "es6", "dom" ],
        "types": [ "node" ]
      },
      "exclude": [ "bin", "node_modules" ],
      "atom": { "rewriteTsconfig": false }
    }
    

    boot-client.ts

    import './polyfills/polyfills.ts';
    import { enableProdMode } from '@angular/core';
    import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
    import { AppModule } from './app/app.module';
    const rootElemTagName = 'app'; // Update this if you change your root component selector
    
    // Enable either Hot Module Reloading or production mode
    if (module['hot']) {
        module['hot'].accept();
        module['hot'].dispose(() => {
            // Before restarting the app, we create a new root element and dispose the old one
            const oldRootElem = document.querySelector(rootElemTagName);
            const newRootElem = document.createElement(rootElemTagName);
            oldRootElem.parentNode.insertBefore(newRootElem, oldRootElem);
            platform.destroy();
        });
    } else {
        enableProdMode();
    }
    
    // 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);
    }
    

    webpack.config.js

    const path = require('path');
    const webpack = require('webpack');
    const merge = require('webpack-merge');
    const CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin;
    
    module.exports = (env) => {
        // Configuration in common to both client-side and server-side bundles
        const isDevBuild = !(env && env.prod);
        const sharedConfig = {
            stats: { modules: false },
            context: __dirname,
            resolve: { extensions: ['.js', '.ts'] },
            output: {
                filename: '[name].js',
                publicPath: '/dist/' // Webpack dev middleware, if enabled, handles requests for this URL prefix
            },
            module: {
                rules: [
                    { test: /\.ts$/, include: /ClientApp/, use: ['awesome-typescript-loader?silent=true', 'angular2-template-loader'] },
                    { test: /\.html$/, use: 'html-loader?minimize=false' },
                    { test: /\.css$/, use: ['to-string-loader', 'css-loader'] },
                    { test: /\.(png|jpg|jpeg|gif|svg)$/, use: 'url-loader?limit=25000' }
                ]
            },
            plugins: [new CheckerPlugin()]
        };
    
        // Configuration for client-side bundle suitable for running in browsers
        const clientBundleOutputDir = './wwwroot/dist';
        const clientBundleConfig = merge(sharedConfig, {
            entry: { 'main-client': './ClientApp/boot-client.ts' },
            output: { path: path.join(__dirname, clientBundleOutputDir) },
            plugins: [
                new webpack.DllReferencePlugin({
                    context: __dirname,
                    manifest: require('./wwwroot/dist/vendor-manifest.json')
                })
            ].concat(isDevBuild ? [
                // Plugins that apply in development builds only
                new webpack.SourceMapDevToolPlugin({
                    filename: '[file].map', // Remove this line if you prefer inline source maps
                    moduleFilenameTemplate: path.relative(clientBundleOutputDir, '[resourcePath]') // Point sourcemap entries to the original file locations on disk
                })
            ] : [
                    // Plugins that apply in production builds only
                    new webpack.optimize.UglifyJsPlugin()
                ])
        });
    
        return [clientBundleConfig];
    };
    
    

    We don't have a boot-server.ts because we removed server side rendering. You may also notice that some of these files have the pieces removed from them that are required for server side rendering. You should be able to disable SSR to see if that is part of the issue.

  27. cbcolleenb commented on Sep 26, 2017

    @cbcolleenb
  28. AmrineA commented on Sep 26, 2017

    @AmrineA
  29. cbcolleenb commented on Sep 27, 2017

    @cbcolleenb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions