steveblue / angular2-rollup

CLI for bundling Angular with Rollup and Closure Compiler
121 stars 18 forks source link

BrowserModule not registered with enabledIvy on prod build #24

Closed matthewharwood closed 6 years ago

matthewharwood commented 6 years ago

Getting BrowserModule not registered when trying to test Ivy and a production build.

Recreation Steps

npm i -g @angular/cli@latest angular-rollup@latest
ngr new my-ivy-app —ivy —angularVersion 7.0.0-rc.1
cd my-ivy-app
npm i tsickle@latest —save-dev

closure.conf:

--js node_modules/@angular/compiler/package.json
--js node_modules/@angular/compiler/fesm2015/compiler.js

"enableIvy": "ngtsc" in src/tsconfig.dev.json and src/tsconfig.prod.json dev:

{
  "extends": "./../tsconfig.json",
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./../dist/my-ivy-app",
    "target": "es5",
    "module": "commonjs",
    "noImplicitAny": false
  },
  "angularCompilerOptions": {
    "skipMetadataEmit": true,
    "enableIvy": "ngtsc"
  },
  "include": [
    "./../src/**/*.ts"
  ]
}

prod:

{
  "extends": "./../tsconfig.json",
  "compilerOptions": {
    "outDir": "./../out-tsc",
    "target": "es2015",
    "module": "es2015",
    "stripInternal": true,
    "inlineSources": true,
    "skipLibCheck": true,
    "allowSyntheticDefaultImports": true,
    "noImplicitAny": false,
    "removeComments": true,
    "allowUnreachableCode": false
  },
  "angularCompilerOptions": {
    "annotationsAs": "static fields",
    "annotateForClosureCompiler": true,
    "skipMetadataEmit": false,
    "enableIvy": "ngtsc"
  },
  "include": [
    "./../src/**/*.ts"
  ]
}

run with

ngr build prod --serve

outputs:

matty@laptop: ~/projects/abc_ivy/my-ivy-app on master [!?]
$ ngr build prod --serve

: Error: Module not registered: BrowserModule
    at SelectorScopeRegistry.lookupScopes (/Users/matty/projects/abc_ivy/my-ivy-app/node_modules/@angular/compiler-cli/src/ngtsc/annotations/src/selector_scope.js:161:23)
    at /Users/matty/projects/abc_ivy/my-ivy-app/node_modules/@angular/compiler-cli/src/ngtsc/annotations/src/selector_scope.js:165:34
    at Array.map (<anonymous>)
    at SelectorScopeRegistry.lookupScopes (/Users/matty/projects/abc_ivy/my-ivy-app/node_modules/@angular/compiler-cli/src/ngtsc/annotations/src/selector_scope.js:164:87)
    at SelectorScopeRegistry.lookupCompilationScope (/Users/matty/projects/abc_ivy/my-ivy-app/node_modules/@angular/compiler-cli/src/ngtsc/annotations/src/selector_scope.js:114:18)
    at ComponentDecoratorHandler.compile (/Users/matty/projects/abc_ivy/my-ivy-app/node_modules/@angular/compiler-cli/src/ngtsc/annotations/src/component.js:128:44)
    at IvyCompilation.compileIvyFieldFor (/Users/matty/projects/abc_ivy/my-ivy-app/node_modules/@angular/compiler-cli/src/ngtsc/transform/src/compilation.js:134:34)
    at IvyVisitor.visitClassDeclaration (/Users/matty/projects/abc_ivy/my-ivy-app/node_modules/@angular/compiler-cli/src/ngtsc/transform/src/transform.js:46:40)
    at /Users/matty/projects/abc_ivy/my-ivy-app/node_modules/@angular/compiler-cli/src/ngtsc/util/src/visitor.js:69:93
    at IvyVisitor.Visitor._visitListEntryNode (/Users/matty/projects/abc_ivy/my-ivy-app/node_modules/@angular/compiler-cli/src/ngtsc/util/src/visitor.js:47:26)
steveblue commented 6 years ago

@matthewharwood just flip the arguments ngr new my-ivy-app --angularVersion 7.0.0-rc.1 --ivy

Sorry for the bad example in the gitter.

In closure.conf you will also have to change the entry point for the ivy bundle.

--entry_point=./out-tsc/main.js
steveblue commented 6 years ago

This scaffold will get updated to be more seamless after angular 7.0.0 is released.