angular / angular-cli

CLI tool for Angular
https://cli.angular.io
MIT License
26.76k stars 11.98k forks source link

Bug: Error when importing the module with an alias #3689

Closed be-ndee closed 7 years ago

be-ndee commented 7 years ago

In my main.ts I have imported the module to use for bootstrapping with an "import as" statement. So it looks like this:

// other imports ...
import { AppModule as MyAppModule } from './app/app.module';

platformBrowserDynamic().bootstrapModule(MyAppModule);

On compiling (./node_modules/.bin/ng build --prod --aot) it throws this error:

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/xxx/development/quickstart/node_modules/@ngtools/webpack/src/entry_resolver.js:131:11)
    at AotPlugin._setupOptions (/Users/xxx/development/quickstart/node_modules/@ngtools/webpack/src/plugin.js:158:54)
    at new AotPlugin (/Users/xxx/development/quickstart/node_modules/@ngtools/webpack/src/plugin.js:17:14)
    at Object.exports.getWebpackAotConfigPartial (/Users/xxx/development/quickstart/node_modules/angular-cli/models/webpack-build-typescript.js:44:13)
    at new NgCliWebpackConfig (/Users/xxx/development/quickstart/node_modules/angular-cli/models/webpack-config.js:25:42)
    at Class.run (/Users/xxx/development/quickstart/node_modules/angular-cli/tasks/build-webpack.js:18:22)
    at Class.run (/Users/xxx/development/quickstart/node_modules/angular-cli/commands/build.js:60:26)
    at Class.<anonymous> (/Users/xxx/development/quickstart/node_modules/angular-cli/ember-cli/lib/models/command.js:152:17)
    at process._tickCallback (internal/process/next_tick.js:103:7)

If I import the module without using the "as" keyword, it works just fine

// other imports ...
import { AppModule } from './app/app.module';

platformBrowserDynamic().bootstrapModule(AppModule);

EDIT package.json dependencies:

  "dependencies": {
    "@angular/common": "^2.3.1",
    "@angular/compiler": "^2.3.1",
    "@angular/core": "^2.3.1",
    "@angular/forms": "^2.3.1",
    "@angular/http": "^2.3.1",
    "@angular/platform-browser": "^2.3.1",
    "@angular/platform-browser-dynamic": "^2.3.1",
    "@angular/router": "^3.3.1",
    "core-js": "^2.4.1",
    "rxjs": "^5.0.1",
    "ts-helpers": "^1.1.1",
    "zone.js": "^0.7.2"
  },
  "devDependencies": {
    "@angular/compiler-cli": "^2.3.1",
    "@types/jasmine": "2.5.38",
    "@types/node": "^6.0.42",
    "angular-cli": "1.0.0-beta.24",
    "codelyzer": "~2.0.0-beta.1",
    "jasmine-core": "2.5.2",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "1.2.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-remap-istanbul": "^0.2.1",
    "protractor": "~4.0.13",
    "ts-node": "1.2.1",
    "tslint": "^4.0.2",
    "typescript": "~2.0.3"
  }
filipesilva commented 7 years ago

Thanks for reporting this issue. This issue is now obsolete due to changes in the recent releases. Please update to the most recent Angular CLI version.

If the problem persists after upgrading, 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[bot] commented 5 years ago

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.