Git Product home page Git Product logo

angular-directive-interactive-demo's Introduction

discussion blog


below instructions are from: https://github.com/csr632/angular-aot-demo-with-ngc-webpack

learn angular aot with ngc and webpack

A minified project to learn Angular5 aot with ngc(Angular compiler cli) and webpack. Also demonstrate how to import 3rd lib such as jQuery.

similar to https://github.com/csr632/angular-aot-demo-with-ngc-rollup, but this project use webpack instead of rollup, so lazy loading Angular module is possible.

feature

This project use ngc to generate compiled Angular code and write it to disk, and then bundle the js code from disk. This make you be able to observe the code generate by angular compiler, and even edit it to see the difference! I think it is really helpful to understand & play with the "low-level machine code" of Angular.

If you just want a minimum configuration to start building your own components to play with the ngc output, switch to mini branch.

command explain:

If you don't care how is the bundle generated and served, just use npm run dev and everything will be watched and updated properly.

  1. npm run compile: use ngc(angular compiler cli) to compile the "angular syntax" into js code(the "low-level machine code"). You can observe the output in compile_output/.
  2. npm run compile:watch: same as npm run compile, except this command will also listen for source files' change and emit latest compiled .js code.
  3. npm run webpack: pack the whole application(including application code, angular framework, 3rd lib) into several bundles, based on the webpack.config.js. Note that the output of ngc is (part of) the input of webpack, so you must have finished npm run compile[:watch] before running this command.
  4. npm run serve: first, bundle the whole application(similar to npm run webpack but will emit files into memory instead of disk and listen for source files' change). Then, serve the emitted files from memory. You must have finished npm run compile[:watch] before running this command (while npm run webpack is not required).
  5. npm run clean: clean dist/*, compile_output/*.
  6. npm run aot: npm run clean && npm run compile && npm run webpack.
  7. npm run dev: bundle and serve the application. This command will listen for source files' change as well as ngc outputs' change. So you can edit these two things and the served bundle will update immediately.

emit control

  • skipMetadataEmit in tsconfig.json determine whether or not Angular Compiler emit .metadata.json files.
  • skipTemplateCodegen in tsconfig.json determine whether or not Angular Compiler emit .ngfactory.js and .ngstyle.js files.
  • declaration in tsconfig.json determine whether or not TypeScript Compiler emit .d.ts definition files.
  • sourceMap in tsconfig.json determine whether or not TypeScript Compiler emit .js.map sourcemap files.

angular-directive-interactive-demo's People

Contributors

csr632 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

greatbear412

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.