router
router copied to clipboard
Dynamic Routing with Webpack
Hi, I have a problem with navigationStrategy. I load only the first time moduleId, then when I change the route the moduleId remains the same even if the route #has the right name . (No error) I use aurelia with webpack.
Thanks
PLATFORM.moduleName('./tipologia/CALDAIA/dettagli');
PLATFORM.moduleName('./tipologia/REFRIGERATORE/dettagli');
PLATFORM.moduleName('./tipologia/SCAMBIATORE/dettagli');
PLATFORM.moduleName('./tipologia/COMPONENTE/dettagli');
PLATFORM.moduleName('./tipologia/BRUCIATORE/dettagli',);
PLATFORM.moduleName('./tipologia/UIR/dettagli');
@autoinject()
export class Installati {
constructor(private router: Router) { }
configureRouter(config: RouterConfiguration, router: Router) {
this.router = router;
const navStrat = (instruction: NavigationInstruction) => {
instruction.config.moduleId = './tipologia/' + instruction.params.TipologiaInstallato + '/dettagli';
instruction.config.href = instruction.fragment;
};
config.map([
{ route: '', name: 'no-selected', moduleId: PLATFORM.moduleName('assistenza/utilities/no-selected') },
{ route: ':TipologiaInstallato/:IdInstallato/*', name: 'dettagli', navigationStrategy: navStrat },
]);
}
}
It's a bit complicated guessing what you want to achieve. Can you help create a small repro describing what the issue? I've prepared a gist https://gist.dumber.app/?gist=5dfee522d31bab9df9bd7c03bf4567f8
how many modules do you have for this pattern?
I can't replicate the error, but thanks for repro. Webpack is the problem, it doesn't load files correctly. I want webpack to load 6 modules and not just the first one used so that through the router parameters I can identify which one I have to use to achieve correct navigation.