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

Slow HMR speed #435

Closed
EricBichara opened this issue Oct 9, 2017 · 7 comments
Closed

Slow HMR speed #435

EricBichara opened this issue Oct 9, 2017 · 7 comments
Labels

Comments

@EricBichara
Copy link

Hot reload takes about 5-6 seconds after any change in the code. Is there anything that can be done to speed this up? This project contains a lot of features, maybe a cleaner project with fewer features would help? By comparison, a clean cli project takes about 1-2 seconds to reload.

@peterdobson
Copy link
Contributor

peterdobson commented Oct 9, 2017

The following tweaks to webpack.config.js: made my HMR much faster in development. See the lines with the "//PD added this" comment.

const clientBundleConfig = merge(sharedConfig, {
        entry: { 'main-client': './ClientApp/boot.browser.ts' },
        output: { path: path.join(__dirname, clientBundleOutputDir) },
        plugins: [
            new webpack.DllReferencePlugin({
                context: __dirname,
                manifest: require('./wwwroot/dist/vendor-manifest.json')
            })
        ].concat(isDevBuild ? [
            // Plugins that apply in development builds only
            new webpack.SourceMapDevToolPlugin({
                filename: '[file].map', // Remove this line if you prefer inline source maps
                moduleFilenameTemplate: path.relative(clientBundleOutputDir, '[resourcePath]') // Point sourcemap entries to the original file locations on disk
            })
        ] : [
            // Plugins that apply in production builds only
            new webpack.optimize.UglifyJsPlugin(),
            new AotPlugin({
                tsConfigPath: './tsconfig.json',
                entryModule: path.join(__dirname, 'ClientApp/app/app.module.browser#AppModule'),
                exclude: ['./**/*.server.ts']
            })
                ])
        ,
        devtool: isDevBuild ? 'cheap-eval-source-map' : ''  //PD added this
    });


const serverBundleConfig = merge(sharedConfig, {
        resolve: { mainFields: ['main'] },
        entry: { 'main-server': './ClientApp/boot.server.ts' },
        plugins: [
            new webpack.DllReferencePlugin({
                context: __dirname,
                manifest: require('./ClientApp/dist/vendor-manifest.json'),
                sourceType: 'commonjs2',
                name: './vendor'
            })
        ].concat(isDevBuild ? [] : [
            new AotPlugin({
                tsConfigPath: './tsconfig.json',
                entryModule: path.join(__dirname, 'ClientApp/app/app.module.server#AppModule'),
                exclude: ['./**/*.browser.ts']
            })
        ]),
        output: {
            libraryTarget: 'commonjs',
            path: path.join(__dirname, './ClientApp/dist')
        },
        target: 'node',
        // switch to "inline-source-map" if you want to debug the TS during SSR
        devtool: isDevBuild ? 'cheap-eval-source-map' : false //PD added this
    });

@EricBichara
Copy link
Author

EricBichara commented Oct 9, 2017

@peterdobson That made a huge difference thanks!!!

@Flood
Copy link
Contributor

Flood commented Oct 9, 2017

@peterdobson

The last line:

devtool: isDevBuild ? 'cheap-eval-source-map' :  'inline-source-map' //PD added this

Shoudn't that be:

devtool: isDevBuild ? 'cheap-eval-source-map' : false //PD added this

Since it was like this before:

devtool: isDevBuild ? 'inline-source-map': false

Otherwise we are adding source maps for production build.

@peterdobson
Copy link
Contributor

yeah thanks @Flood I think you are right

@davidsekar
Copy link
Contributor

If you need to debug the Typescript that runs on the Server side (i.e., while Server Side Rendering initial HTML). Then 'inline-source-map' is the best as it maps to the exact source line of .ts file & shows that in the dev toolbar....

But if SSR debugging is not required, then devtool can be false ( as cheap-eval-source-map will map some things to the transpiled JS, so not that useful)

@peterdobson Thanks for your pointer on how to improve HMR build speed.

@MarkPieszak
Copy link
Member

Added this in the #437 upcoming 5.0 release, thank you Peter! I left it as inline as default figuring people would want that TS SSR debugging, but instead I put a note in there.

Overall I'm sure people won't need it, and would prefer faster rebuilds :)

Thanks again! 🍺

MarkPieszak added a commit that referenced this issue Nov 2, 2017
* feat(5.0): update engine-etc for angular 5.0-rc1

WIP - More updates to come

* remove ng 4 references

* update source maps for faster HMR builds

* use aspnetcore-engine & misc updates and fixes

* update to 5.0 official

Closes #434
Closes #435
Closes #430
Closes #424
BillSheldon-HunterIndustries pushed a commit to BillSheldon-HunterIndustries/aspnetcore-angular2-universal that referenced this issue Jan 17, 2018
…IO#437)

* feat(5.0): update engine-etc for angular 5.0-rc1

WIP - More updates to come

* remove ng 4 references

* update source maps for faster HMR builds

* use aspnetcore-engine & misc updates and fixes

* update to 5.0 official

Closes TrilonIO#434
Closes TrilonIO#435
Closes TrilonIO#430
Closes TrilonIO#424
BillSheldon-HunterIndustries pushed a commit to BillSheldon-HunterIndustries/aspnetcore-angular2-universal that referenced this issue May 15, 2018
…IO#437)

* feat(5.0): update engine-etc for angular 5.0-rc1

WIP - More updates to come

* remove ng 4 references

* update source maps for faster HMR builds

* use aspnetcore-engine & misc updates and fixes

* update to 5.0 official

Closes TrilonIO#434
Closes TrilonIO#435
Closes TrilonIO#430
Closes TrilonIO#424
BillSheldon-HunterIndustries pushed a commit to BillSheldon-HunterIndustries/aspnetcore-angular2-universal that referenced this issue May 15, 2018
…IO#437)

* feat(5.0): update engine-etc for angular 5.0-rc1

WIP - More updates to come

* remove ng 4 references

* update source maps for faster HMR builds

* use aspnetcore-engine & misc updates and fixes

* update to 5.0 official

Closes TrilonIO#434
Closes TrilonIO#435
Closes TrilonIO#430
Closes TrilonIO#424
BillSheldon-HunterIndustries pushed a commit to Hunter-Industries/aspnetcore-angular2-universal that referenced this issue May 16, 2018
…IO#437)

* feat(5.0): update engine-etc for angular 5.0-rc1

WIP - More updates to come

* remove ng 4 references

* update source maps for faster HMR builds

* use aspnetcore-engine & misc updates and fixes

* update to 5.0 official

Closes TrilonIO#434
Closes TrilonIO#435
Closes TrilonIO#430
Closes TrilonIO#424
BillSheldon-HunterIndustries pushed a commit to BillSheldon-HunterIndustries/aspnetcore-angular2-universal that referenced this issue Jun 8, 2018
…IO#437)

* feat(5.0): update engine-etc for angular 5.0-rc1

WIP - More updates to come

* remove ng 4 references

* update source maps for faster HMR builds

* use aspnetcore-engine & misc updates and fixes

* update to 5.0 official

Closes TrilonIO#434
Closes TrilonIO#435
Closes TrilonIO#430
Closes TrilonIO#424
BillSheldon-HunterIndustries pushed a commit to BillSheldon-HunterIndustries/aspnetcore-angular2-universal that referenced this issue Jun 8, 2018
…IO#437)

* feat(5.0): update engine-etc for angular 5.0-rc1

WIP - More updates to come

* remove ng 4 references

* update source maps for faster HMR builds

* use aspnetcore-engine & misc updates and fixes

* update to 5.0 official

Closes TrilonIO#434
Closes TrilonIO#435
Closes TrilonIO#430
Closes TrilonIO#424
BillSheldon-HunterIndustries pushed a commit to BillSheldon-HunterIndustries/aspnetcore-angular2-universal that referenced this issue Jun 8, 2018
…IO#437)

* feat(5.0): update engine-etc for angular 5.0-rc1

WIP - More updates to come

* remove ng 4 references

* update source maps for faster HMR builds

* use aspnetcore-engine & misc updates and fixes

* update to 5.0 official

Closes TrilonIO#434
Closes TrilonIO#435
Closes TrilonIO#430
Closes TrilonIO#424
BillSheldon-HunterIndustries pushed a commit to BillSheldon-HunterIndustries/aspnetcore-angular2-universal that referenced this issue Jun 8, 2018
…IO#437)

* feat(5.0): update engine-etc for angular 5.0-rc1

WIP - More updates to come

* remove ng 4 references

* update source maps for faster HMR builds

* use aspnetcore-engine & misc updates and fixes

* update to 5.0 official

Closes TrilonIO#434
Closes TrilonIO#435
Closes TrilonIO#430
Closes TrilonIO#424
@quedicesebas
Copy link

Hey, I'm facing slow speeds with angular 7, please help me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants