Skip to content

Built module distribution cannot be imported to other modules #6378

Closed

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.

Activity

  1. clydin commented on May 18, 2017

    @clydin
    Member

    The CLI currently only generates an application. Library creation is a planned future feature.

  2. ajcrites commented on May 18, 2017

    @ajcrites
    Author

    @clydin understandable, but in the meantime is there anywhere I can find information about how to build libraries?

  3. ajcrites commented on May 18, 2017

    @ajcrites
    Author
  4. loixlab commented on Jun 16, 2017

    @loixlab

    @ajcrites This repo is a very good starter for a library:
    https://github.com/filipesilva/angular-quickstart-lib

  5. angular-automatic-lock-bot commented on Sep 7, 2019

    @angular-automatic-lock-bot

    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.

  6. locked and limited conversation to collaborators on Sep 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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