Skip to content

AOT error when importing module outside of src folder #5990

Closed
@elclanrs

Description

@elclanrs

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Versions.

@angular/cli: 1.0.0
node: 6.10.2
os: darwin x64

Repro steps.

ng new my-project
cd my-project
ng g module my-component
ng g component my-component
touch index.ts

Create module in index.ts:

import { NgModule } from '@angular/core';
import { MyComponentModule } from './src/app/my-component/my-component.module';

@NgModule({
  imports: [ MyComponentModule ],
  exports: [ MyComponentModule ]
})
class MyPublishModule {
}

Import index.ts module in src/app/app.module.ts:

...
import { MyPublishModule } from '../../';

@NgModule({
  ...
  imports: [
    ...
    MyPublishModule
  ]
  ...
})
...

Now ng serve works fine, but ng build --prod does not; it fails with this error:

ERROR in /Users/elclanrs/Documents/my-project/src/$$_gendir/index.ngfactory.ts
 (1,1): Cannot find module './index'.
/Users/elclanrs/Documents/my-project/src/$$_gendir/index.ngfactory.ts (1,1): C
annot find module './src/app/my-component/my-component.module'.

This worked fine before v1.0.0 in Angular 2.4. If I move the index.ts module to src/index.ts and adjust the paths, then it works.

Also, ngc doesn't complain. Any ideas what changed that caused this issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgenteffort2: medium (days)freq1: lowOnly reported by a handful of users who observe it rarelyneeds: investigationRequires some digging to determine if action is neededseverity2: inconvenient

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions