Coder Social home page Coder Social logo

georemo / angular-umd-dynamic-example Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lmeijdam/angular-umd-dynamic-example

0.0 0.0 0.0 246 KB

Angular UMD example of loading new modules dynamically

JavaScript 12.43% TypeScript 79.91% HTML 7.50% CSS 0.15%

angular-umd-dynamic-example's Introduction

Angular Dynamic UMD Module Loading

This is an experimental branch from https://github.com/lmeijdam/angular-umd-dynamic-example. Dynamic module loading in Angular has been subject has attracted several developers. Having looked at several efforts and ideas, I have forked this particular one to try and extend it further with some useful features.

Target Features:

  1. Side Menu with a menu item holding link to dashboard for managing modules
  2. Enabled Modules should be displayed in the menu list
  3. Interface for downloading remote modules in a secure and procedural way. IDE plugin interfaces are inspiring

How to start

Clone or download this repository;

git clone https://github.com/lmeijdam/angular-umd-dynamic-example

Navigate to the folder and install all dependencies;

npm install

By default I've added the UMD bundles from ModuleA, ModuleB, ModuleC and ModuleD. Also modules A and C are registered by default. This means they will get loaded when the app gets initialized.

Updating a module/library

When you want to make updates to one of the existing modules you can just update the source files in 'projects/(moduletoedit)/src/lib' and rebuilding that specific module with the Angular CLI;

cd /moduleName ng build libraryName

After build you're able to replace the contents of that module in the 'assets' folder in either the dist folder or on the hosted environment. If you've added new dependencies like third party libraries and want to use them in the library. Make sure to update the 'modules' array in the module.service.ts and recompile.

Adding a new module/library

When you want to add a new library/module please make use of the Angular CLI command;

ng generate library (libraryName)

Edit the modules.json file with the correct module information and also make sure to have the RouterModule.forChild([]) configuration done in the module of the library.

In the original source you'll find an example to load up component dynamically and instantiate them in a ViewChild instead of extending the Router.

Now build the module with

ng build LibraryName

and copy the umd bundle to the 'assets' folder.

AOT and SystemJS

The app now supports AOT compilation by typing;

ng build --aot

Next to that I've changed the use of eval to the use of SystemJS to load the modules.

Running the application

For the application I've used https://www.npmjs.com/package/http-server which let your application run on port 8080 by default. After install you're able to run this application locally

npm install -g http-server

http-server ./dist/angular-dynamic-demo

Notes

angular-umd-dynamic-example's People

Contributors

georemo avatar lmeijdam 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.