Importing only DefaultUrlSerializer class into Angular project without the whole router module
The following import statement pulls the entire router module into the final webpack package.
import { DefaultUrlSerializer } from '@angular/router';
Is there a way to import DefaultUrlSerializer
without another irrelevant module?
I am using Webpack and Angular Cli module builder to build AOT / production.
source to share
No, you cannot do this unless you build Angular yourself. The package npm
does not send modules separately, but as one package in the UMD format:
node_modules
@angular
router
bundles
router.umd.js
Regardless of how you import DefaultUrlSerializer
, webpack will contain the content of everything router.umd.js
in the final build, since it cannot extract the code from the file.
source to share