0

I am building an Angular module manually with Webpack without using the CLI.
When doing normal build it works, when doing AOT build it doesn't!

The tsconfig.aot.json is as follows:

{
  "compilerOptions": {
    "target": "es5",
    "module": "es2015",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es5",
      "es2015",
      "dom"
    ]
  },
  "angularCompilerOptions": {
    "skipMetadataEmit": true,
    "genDir": "aot"
  }
}

The errors are mostly related to Typescript:

ERROR in [at-loader] ./node_modules/@types/core-js/index.d.ts:829:20 TS2304: Cannot find name 'PromiseConstructor'.

ERROR in [at-loader] ./node_modules/@types/core-js/index.d.ts:1486:36 TS2339: Property 'for' does not exist on type 'SymbolConstructor'.

ERROR in [at-loader] ./node_modules/@types/core-js/index.d.ts:1490:43 TS2339: Property 'hasInstance' does not exist on type 'SymbolConstructor'.

ERROR in [at-loader] ./node_modules/@types/core-js/index.d.ts:2305:36 TS2339: Property 'for' does not exist on type 'SymbolConstructor'.

ERROR in [at-loader] ./node_modules/@types/core-js/index.d.ts:2309:43 TS2339: Property 'hasInstance' does not exist on type 'SymbolConstructor'.

ERROR in [at-loader] ./node_modules/@types/core-js/index.d.ts:2313:50 TS2339: Property 'isConcatSpreadable' does not exist on type 'SymbolConstructor'.

ERROR in [at-loader] ./node_modules/rxjs/internal/Observable.d.ts:82:59 TS2693: 'Promise' only refers to a type, but is being used as a value here.

5
  • What is your @types/core-js version? Commented Oct 11, 2018 at 8:23
  • "@types/core-js": "~2.5.0", Commented Oct 11, 2018 at 8:40
  • are you getting any error while compiling the code with ng serve? Commented Oct 11, 2018 at 8:49
  • Since the errors seem to be in the library, if you want, you can disable TS from checking library types. For that add "skipLibCheck": true, to compilerOptions in tsconfig.json Commented Oct 11, 2018 at 9:07
  • @BlizZard I am not using CLI, I am doing it manually. npm run build works fine, when I run npm run build:prod I get the issues with types. Thanks Commented Oct 11, 2018 at 9:11

2 Answers 2

0

The reason the normal build "works" is because you have the transpileOnly: true option set on awesome-typescript-loader, which disables all type error reporting. Once I remove that option and set the lib settings the same in both tsconfig.json and tsconfig.aot.json, I get roughly the same errors from both npm run build and npm run build:prod.

Starting from the zip file you posted, one configuration that worked for me was to upgrade @types/core-js to the latest version as of this writing (2.5.0, which is a much closer match to your core-js version of 2.5.7 than @types/core-js 0.9.* was) and then change the target to es6 (and remove the overriding lib options) in both tsconfig.json and tsconfig.aot.json. After doing this, both npm run build and npm run build:prod completed without error for me.

Sign up to request clarification or add additional context in comments.

Comments

-1

Use "@types/core-js": "0.9.35" in you package.json and then run npm install. That will fix it.

1 Comment

Even more errors. I've uploaded the small project here: drive.google.com/open?id=1li-zzJLDSVfSAOAYNcTG8AKz5qXREHJp

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.