Skip to content

AOT error when importing module outside of src folder #5990

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

Closed
elclanrs opened this issue Apr 18, 2017 · 3 comments
Closed

AOT error when importing module outside of src folder #5990

elclanrs opened this issue Apr 18, 2017 · 3 comments
Labels
effort2: medium (days) freq1: low Only reported by a handful of users who observe it rarely needs: investigation Requires some digging to determine if action is needed P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent severity2: inconvenient

Comments

@elclanrs
Copy link

elclanrs commented Apr 18, 2017

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?

@elclanrs elclanrs changed the title AOT error importing module outside of src folder AOT error when importing module outside of src folder Apr 18, 2017
@filipesilva filipesilva added effort2: medium (days) freq1: low Only reported by a handful of users who observe it rarely needs: investigation Requires some digging to determine if action is needed P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent severity2: inconvenient labels May 5, 2017
@kylecordes
Copy link

How about a set of tests that assert CLI can handle various cases that NGC an handle? Should CLI be able to handle any input that NGC handles?

@alan-agius4
Copy link
Collaborator

The problem in the repo above seems to be that MyPublishModule is not exported.

Changing class MyPublishModule to export class MyPublishModule results in the application to be compiled successfully.

If the problem persists please open a new issue, provide a simple repository reproducing the problem, and describe the difference between the expected and current behavior.

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
effort2: medium (days) freq1: low Only reported by a handful of users who observe it rarely needs: investigation Requires some digging to determine if action is needed P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent severity2: inconvenient
Projects
None yet
Development

No branches or pull requests

5 participants