Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4 steps to convert angular app to angular lazy module #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bolshchikov
Copy link
Member

@bolshchikov bolshchikov commented Apr 16, 2017

Step 1: Add react-module-container

Add react-module-container npm module as your dependency. Run

npm install --save react-module-container

Step 2: Create manifest file and register your component

Create a manifest.js file that describe your future lazy module. It can be either Angular or React lazy module.

class NgMainApp extends AngularLazyComponent {
  constructor(props) {
    super(props, {
      files: [
        `${props.topology.staticsBaseUrl}angular-client.css`,
        `${props.topology.staticsBaseUrl}angular-client.bundle.js`
      ],
      module: 'myApp',
      component: 'main-app',
      unloadStylesOnDestroy: true
    });
  }
}

ModuleRegistry.registerComponent('angular.main', () => NgMainApp);

Step 3: Load the manifest file by hosting application

Load manifest.js file in the index.html of your hosting application.

<script src="<path-to-your-manifest-file>/manifest.js"></script>

Step 4: Instantiate your lazy component

Instantiate your lazy component using ModuleRegistry and render it inside hosting application.

@bolshchikov bolshchikov changed the title How to convert angular app to angular lazy module 4 steps to convert angular app to angular lazy module Apr 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant