Skip to content

CLI force me to have bootstrapModule in my main module #6466

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
yordis opened this issue May 25, 2017 · 9 comments
Closed

CLI force me to have bootstrapModule in my main module #6466

yordis opened this issue May 25, 2017 · 9 comments

Comments

@yordis
Copy link

yordis commented May 25, 2017

Bug Report or Feature Request (mark with an x)

- [x] bug report
- [ ] feature request

Versions.

@angular/cli: 1.0.1
node: 7.10.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.

The log given by the failure.

  1. Setup an application on .angular-cli.json
  2. Remove platformBrowserDynamic().bootstrapModule(DemoModule) from the main project
  3. Try to run the test task for that application
  4. It will show Tried to find bootstrap code, but could not. Specify either statically analyzable bootstrap code or pass in an entryModule to the plugins options.
$ ng test --app boa
Tried to find bootstrap code, but could not. Specify either statically analyzable bootstrap code or pass in an entryModule to the plugins options.
Error: Tried to find bootstrap code, but could not. Specify either statically analyzable bootstrap code or pass in an entryModule to the plugins options.
    at Object.resolveEntryModuleFromMain (/Users/ubi/Sites/open_source/boa/node_modules/@ngtools/webpack/src/entry_resolver.js:118:15)
    at AotPlugin._setupOptions (/Users/ubi/Sites/open_source/boa/node_modules/@ngtools/webpack/src/plugin.js:143:50)
    at new AotPlugin (/Users/ubi/Sites/open_source/boa/node_modules/@ngtools/webpack/src/plugin.js:26:14)
    at _createAotPlugin (/Users/ubi/Sites/open_source/boa/node_modules/@angular/cli/models/webpack-configs/typescript.js:55:12)
    at Object.exports.getNonAotTestConfig (/Users/ubi/Sites/open_source/boa/node_modules/@angular/cli/models/webpack-configs/typescript.js:103:19)
    at WebpackTestConfig.buildConfig (/Users/ubi/Sites/open_source/boa/node_modules/@angular/cli/models/webpack-test-config.js:17:31)
    at init (/Users/ubi/Sites/open_source/boa/node_modules/@angular/cli/plugins/karma.js:79:94)
    at Array.invoke (/Users/ubi/Sites/open_source/boa/node_modules/di/lib/injector.js:75:15)
    at Injector.get (/Users/ubi/Sites/open_source/boa/node_modules/di/lib/injector.js:48:43)
    at /Users/ubi/Sites/open_source/boa/node_modules/karma/lib/server.js:143:20
    at Array.forEach (native)
    at Server._start (/Users/ubi/Sites/open_source/boa/node_modules/karma/lib/server.js:142:21)
    at Injector.invoke (/Users/ubi/Sites/open_source/boa/node_modules/di/lib/injector.js:75:15)
    at Server.start (/Users/ubi/Sites/open_source/boa/node_modules/karma/lib/server.js:103:18)
    at Promise (/Users/ubi/Sites/open_source/boa/node_modules/@angular/cli/tasks/test.js:35:25)
    at Class.run (/Users/ubi/Sites/open_source/boa/node_modules/@angular/cli/tasks/test.js:15:16)
error Command failed with exit code 1.

Desired functionality.

The test should run without force me to have a bootstrapped application.

Mention any other details that might be useful.

Repo: https://github.com/straw-hat-llc/boa/tree/develop
This project is trying to create a UI framework for be used cross multiple applications. Because of that, I actually don't have an application (unless I am misunderstanding Angular), I actually have a bunch of code that compose a UI framework.

I am using boa app https://github.com/straw-hat-llc/boa/blob/develop/.angular-cli.json#L8 for setup the testing piece of the framework, just the spec testing because the e2e will be excluded, but because my main file do not contains a bootstrapModule the task is failing.

This should let me run the testing, base on this use case, I do not need a real application to be able to run. I am trying to test an framework code, no a real application (from the point of view that this is no meant to be deploy by it's own)

@yordis
Copy link
Author

yordis commented May 25, 2017

demo app https://github.com/straw-hat-llc/boa/blob/develop/.angular-cli.json#L20 is used for development, where you could add your use cases of the component and you can test it out visually. Also I will add website app which it will be used for github pages website

@dherges
Copy link

dherges commented May 29, 2017

Can you try setting entryModule for the AotPlugin from @ngtools/webpack?

The error message tells half of the story: either statically analyzable bootstrap code or pass in an entryModule to the plugins options. You will need to ng eject your webpack config, and then edit the webpack plugin options. I think it is documented behaviour actually.

@yordis
Copy link
Author

yordis commented May 29, 2017

@dherges what do you mean by webpack config? I do not have any Webpack file at all. I am using ng-cli generated code for this. I only have the .angular-cli.json config so far https://github.com/straw-hat-llc/boa/blob/develop/.angular-cli.json

@clydin
Copy link
Member

clydin commented May 29, 2017

The CLI is currently only intended for the creation of web applications. However, library creation support is planned for a future release.

@yordis
Copy link
Author

yordis commented May 29, 2017

@clydin is there any issue related to that? I want to follow the thread and see if I can help somehow the process

@dherges
Copy link

dherges commented May 30, 2017

@yordis there are two independent things here:

  • authoring a library: you need to build it in Angular Package Format, you could write your own build scripts or use a tool like ng-packagr
  • the ng cli: it uses webpack under the hood. you can ng eject its config.

@yordis
Copy link
Author

yordis commented May 30, 2017

@dherges so is my concern a valid issue/concern? I don't mind to wait if what @clydin said it's true.

I see many use cases where I have some "app" that are just framework/library code but I want to run some tasks from the CLI independently.

@hansl
Copy link
Contributor

hansl commented May 30, 2017

@yordis Hi. We do not support libraries at the moment. What you're seeing is failure from our code to find the entry NgModule, and if it cannot find it it will fail. We need that information for knowing where to start looking for routes. If you only want to run tests, you should be able to setup karma yourself and use the karma CLI.

For more information regarding libraries, see my comment here: #1692 (comment)

I'm going to close this as Working-As-Intended.

@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 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants