angular / angular-cli

CLI tool for Angular
https://cli.angular.io
MIT License
26.76k stars 11.98k forks source link

Function in route generation causes lazy module to be unreachable #2546

Closed itsJess1ca closed 8 years ago

itsJess1ca commented 8 years ago

OS?

Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?) Windows 10

Versions.

Please run ng --version. If there's nothing outputted, please run in a Terminal: node --version and paste the result here: angular-cli: 1.0.0-beta.16 node: 6.4.0 os: win32 x64

Repro steps.

Was this an app that wasn't created using the CLI? What change did you do on your code? etc. Current behavior When using a function to tidy route generation, eg:

const LazyRoute = (path: string, moduleName: string, dir?: string) => ({
  path: path,
  loadChildren: `app/core/+${dir ? dir : path}/${dir ? dir : path}.module#${moduleName}`
});
const LAZY_ROUTES = [
  LazyRoute('moderators', 'ModeratorModule'),
  LazyRoute('settings', 'SettingsModule'),
  LazyRoute('blog', 'BlogModule'),
  LazyRoute('help', 'HelpModule'),
  LazyRoute('wishlist', 'WishlistModule'),
  LazyRoute(':name', 'DashboardModule', 'dashboard')
];

The above setup logs out correctly, and should be functional, however routing to the module causes 'module cannot be found' errors (while giving the correct path in the error log)

I have copied the outputs from these functions and used them directly in the route configs, instead of abstracting to functions, and the app successfully loads and runs perfectly.

The log given by the failure.

Normally this include a stack trace and some more information. In browser (Chrome 55.0.2880.4 canary) console: When navigating to /settings/account for example: Error: Cannot find module 'app/core/+settings/settings.module'.

filipesilva commented 8 years ago

Dupe of https://github.com/angular/angular-cli/issues/2485

angular-automatic-lock-bot[bot] commented 5 years ago

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.