Coder Social home page Coder Social logo

module-loading's Introduction

module-loading

This repo has 2 examples of how to dynamically load Modules in Angular

Static

This shows how you can load in a module similar to how @angular/router does.
Here we require the module to be known at build time.
Do note that it also makes use of a private API on this line

const compType = moduleFactories['LazyCompNgFactory']._componentType;

Noted by the _, do not use this API unless you want to risk it being broken in the future since private API's are not subject to any of Angular's policies on breaking changes.
This is mainly for comparison to the more dynamic way.

Dynamic

This is the main feature of this repository.
Here the plugin (Angular module) does not need to be known at build time for the main application to be built.
With this method you can make plugins independantly of the main application.
This is accomplished through the use of Webpack and Rollup and externalising dependencies.
However, the issue with doing this is that all your dependencies must be loaded in as UMD bundles, which means that you loose all global optimisations. Meaning that you wont be able to do tree shaking or similar optimisations.

If you have any questions feel free to make an issue or ping on on Gitter with @Toxicable

module-loading's People

Contributors

angular-cli avatar

Watchers

Sébastien Minne avatar

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.