Angular 2 compilation works with tsc and ngc but not tsickle
See original GitHub issueI’m new to build tools in general, so I’m probably making a silly error. Ask for more info and I’ll provide.
I have an Angular 2
application written in typsecript 2
. I can use tsc
to compile it without problem. I’m now trying to optimize:
Typescript >> Ahead-of-Time compiler (ngc) >> tsickle >> google-closure-compiler-js
My dev/main.ts
(bootstrap file for my Angular 2 app):
1| //import dependencies (core-js, zone.js, reflect-metadata)
2| import 'core-js';
3| import 'reflect-metadata';
4| import 'zone.js';
5| // AHEAD-OF-TIME COMPILATION
6| import {platformBrowser} from '@angular/platform-browser';
7| import {AppModuleNgFactory} from '../aot/dev/app/app.module.ngfactory' //generated code
8| platformBrowser().bootstrapModuleFactory(AppModuleNgFactory);
After I’ve run ngc
(successfully), I’m not sure how to properly use tsickle
. I’ve tried:
"node_modules/.bin/tsickle" -- -p ./
Error at /dev/main.ts:6:9: Import declaration conflicts with local declaration of ‘platformBrowser’ Error at /dev/main.ts:7:24: Cannot find name ‘NeverTypeCheckMe’. Error at /dev/main.ts:7:43: Block-scoped variable ‘platformBrowser’ used before its declaration. Error at /dev/main.ts:8:9: Import declaration conflicts with local declaration of ‘AppModuleNgFactory’ Error at /dev/main.ts:9:27: Cannot find name ‘NeverTypeCheckMe’. Error at /dev/main.ts:9:46: Block-scoped variable ‘AppModuleNgFactory’ used before its declaration.
What’s causing these errors? There is no local declaration, so how can it conflict with imports?
tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "es2015",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"outDir": "./dist",
"baseUrl": "."
},
"compileOnSave": false,
"files": ["./dev/main.ts","./dev/app/custom.typings.d.ts"]
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (1 by maintainers)
Top GitHub Comments
I was able to get the contents of
build/
andnode_modules/
directories by:npm install
compile
I then copied the two directories and replaced the matching dirs in my project:
Once I succeeded, The compilation completed without raising any error.
@RoxKilly I would’ve given up had I not read your comments. Still haven’t succeeded though.
update: Ah, I wasn’t using the local project version of tsickle.