Files excluded in tsconfig.json is being built in ngc during ionic build --prod


#1

I’m getting an error message of the following during ionic build --prod :

[17:22:33]  ionic-app-scripts 1.3.4
[17:22:33]  build prod started ...
[17:22:33]  clean started ...
[17:22:33]  clean finished in 1 ms
[17:22:33]  copy started ...
[17:22:33]  ngc started ...
[17:22:35]  ionic-app-script task: "build"
[17:22:35]  Error: Cannot determine the module for class SlidesMock in
            /Users/.../src/mocks/ionic/slides.mock.ts! Add SlidesMock to the NgModule to fix it.
Error: Cannot determine the module for class SlidesMock in /Users/.../src/mocks/ionic/slides.mock.ts! Add SlidesMock to the NgModule to fix it.

I have a couple of files in src/mocks/*.mock.ts that keeps showing up during ngc when I’m doing build --prod. I already have the following tsconfig.json. What else do I need to exclude them? I try adding the exclude array to all the other tsconfig.json, such as src/tsconfig.app.json and src/tsconfig/spec.json, and tsconfig.ng-cli.json. None works. Below is tsconfig.json.

{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [
      "dom",
      "es2015"
    ],
    "module": "es2015",
    "moduleResolution": "node",
    "sourceMap": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "types": [
     "jasmine",
     "node"
   ]
  },
  "include": [
    "src/**/*.ts",
    "node_modules/@types"
  ],
  "exclude": [
    "**/*.mock.ts",
    "**/test.ts"
  ],
  "compileOnSave": false,
  "atom": {
    "rewriteTsconfig": false
  }
}

#2

Your “include” is killing you. Get rid of it entirely.


#3

@heykamok Not only that, this is an Angular style build.
I’m also curious about importing “node_modules@types”. Ionic usually disallow that, no?