shlomiassaf / ngc-webpack

Angular compiler-cli with webpack's loader chain.
MIT License
84 stars 15 forks source link

Garbage files are created in project root #15

Closed bisubus closed 7 years ago

bisubus commented 7 years ago

For each *.ts file a set of garbage files is created nearby, starting from project root:

*.js,*.js.map,*.ngsummary.json,*.ngfactory.js,*.ngfactory.js.map

*.ngsummary.json,*.ngfactory.js,*.ngfactory.js.map are duplicated in genDir (<project-root>/aot/), *.js,*.js.map are not.

This does not happen when the project is being built without ngc-webpack and AoT with the same configuration (just awesome-typescript-loader and JiT).

The setup is loosely based on https://github.com/AngularClass/angular2-webpack-starter and is quite ordinary, here are the most relevant details:

package.json

  ...
  "devDependencies": {
    "@angular/compiler-cli": "^4.0.2",
    "ngc-webpack": "^2.0.0",
    "awesome-typescript-loader": "^3.0.0",
    "typescript": "~2.2.0",
    "webpack": "~2.4.1",
    ...
  },
  ...

webpack.config.js

module.exports = {
    entry: {
        'polyfills': './src/polyfills.ts',
        'main': process.env.AOT
            ? './src/main.aot.ts'
            : './src/main.jit.ts'
    },

    resolve: {
        extensions: ['.ts', '.js', '.json'],
        modules: [
            path.join(ROOT, 'src'),
            NODE_MODULES
        ]
    },

    module: {
        loaders: [
            {
                test: /\.ts$/,
                loaders: [
                    {
                        loader: 'awesome-typescript-loader',
                        options: { configFileName: 'tsconfig.json' }
                    }
                ],
                exclude: [/\.(spec|e2e)\.ts$/]
            },
            {
                test: /\.json$/,
                loader: 'json-loader'
            },
            ...
        ]
    },

    plugins: [
        new CommonsChunkPlugin({ name: ['polyfills'] }),
        new CheckerPlugin,
        new ngcWebpack.NgcWebpackPlugin({
            disabled: !process.env.AOT,
            tsConfig: path.join(ROOT, 'tsconfig.json'),
            resourceOverride: path.join(ROOT_PATH, 'aot-empty-resource.js')
        })
    ],

    node: {
        global: true,
        crypto: 'empty',
        process: true,
        module: false,
        clearImmediate: false,
        setImmediate: false
    }
}

tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "module": "es2015",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "alwaysStrict": true,
    "sourceMap": true,
    "noEmitHelpers": true,
    "importHelpers": true,
    "strictNullChecks": false,
    "baseUrl": "./src",
    "paths": [],
    "lib": [
      "dom",
      "es5"
    ],
    "types": [...],
    "typeRoots": ["./node_modules/@types"]
  },
  "exclude": [
    "node_modules",
    "dist"
  ],
  "compileOnSave": false,
  "buildOnSave": false
}
artaommahe commented 7 years ago

@bisubus add "noEmit": true, to compiler options

bisubus commented 7 years ago

@artaommahe Thank you, this likely should help indeed. I'll reopen the issue if the problem won't be solved.

ghost commented 6 years ago

Where does tsconfig.json live in a standard app created with angular-cli? I am asking because a simple linux 'find' command shows nothing. I suspect it got accidentally deleted.