Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

fix(Angular): add hot loader for lazy loaded NgModules #747

Merged
merged 3 commits into from
Dec 18, 2018

Conversation

sis0k0
Copy link
Contributor

@sis0k0 sis0k0 commented Dec 17, 2018

What is the current behavior?

In NativeScript Angular the hot updates are only accepted in the entry file (main.ts). The lazy loaded NgModules are not directly imported anywhere in the dependency graph with root main.ts. That's why the hot updates in lazy modules don't bubble up to the accept in main.ts and HMR doesn't work in lazy modules.

What is the new behavior?

Every lazy loaded NgModule is augmented with HMR self-accept during build by the lazy-ngmodule-hot-loader.

fixes NativeScript/nativescript-angular#1564

BREAKING CHANGES:

The lazy-ngmodule-hot-loader should be added to the webpack configuration.

BEFORE

// webpack.config.js
                {
                    test: /(?:\.ngfactory\.js|\.ngstyle\.js|\.ts)$/,
                    use: [
                        "nativescript-dev-webpack/moduleid-compat-loader",
                        "@ngtools/webpack",
                    ]
                },
// ...

AFTER

// webpack.config.js
                {
                    test: /(?:\.ngfactory\.js|\.ngstyle\.js|\.ts)$/,
                    use: [
                        "nativescript-dev-webpack/moduleid-compat-loader",
                        "nativescript-dev-webpack/lazy-ngmodule-hot-loader",
                        "@ngtools/webpack",
                    ]
                },
// ...

@sis0k0 sis0k0 self-assigned this Dec 17, 2018
@sis0k0 sis0k0 merged commit 6a9db32 into master Dec 18, 2018
@sis0k0 sis0k0 deleted the sis0k0/lazy-hmr branch December 18, 2018 11:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HMR does not work for Angular projects, containing lazy loaded modules and the code snippet
2 participants