Skip to content

Built module distribution cannot be imported to other modules #6378

@ajcrites

Description

@ajcrites

Bug Report or Feature Request (mark with an x)

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

Versions.

@angular/cli: 1.0.1
node: 7.9.0
os: darwin x64
@angular/common: 4.1.3
@angular/compiler: 4.1.3
@angular/core: 4.1.3
@angular/forms: 4.1.3
@angular/http: 4.1.3
@angular/platform-browser: 4.1.3
@angular/platform-browser-dynamic: 4.1.3
@angular/router: 4.1.3
@angular/cli: 1.0.1
@angular/compiler-cli: 4.1.3

Repro steps.

  1. Create a module using ng new or by any other means
  2. Export a module from the built code. E.g., you can do
    @NgModule()
    export class SimplestModule { }
    
    inside of src/main.ts that gets generated by the new project.
  3. Create a second Angular project. Using ng new is fine.
  4. Import the exported module in your new project.
    import { SimplestModule } from '/path/to/other/module/dist/main.bundle';
    @NgModule({
      declarations: [ AppComponent ],
      imports: [ SimplestModule ],
      bootstrap: [AppComponent]
    })
    export class AppModule { }
    

If you import { SimplestModule } the result will be undefined. If you import SimplestModule (i.e. module.exports that gets created), you will get an undecorated object.

The log given by the failure.

From the project attempting to import:

Unexpected value XXX imported by the module 'AppModule'

Desired functionality.

You should be able to use ng to build modules that can be imported into other modules. Currently modules that are built do not appear to be ready to be imported by other modules post-build.

In general it would be nice to have more documentation / tools surrounding the creation of third party modules or modules that are intended to be reused by other modules.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions