fix(compiler-cli): prevent ng-xi18n from emitting the compilation output (#14115)

fixes #13567

PR Close #14115
This commit is contained in:
Marc Laval 2017-01-26 10:27:07 +01:00 committed by Miško Hevery
parent 7036e04ec6
commit e58d683931
4 changed files with 44 additions and 4 deletions

View File

@ -65,6 +65,7 @@ const EXPECTED_XLIFF = `<?xml version="1.0" encoding="UTF-8" ?>
describe('template i18n extraction output', () => {
const outDir = '';
const genDir = 'out';
it('should extract i18n messages as xmb', () => {
const xmbOutput = path.join(outDir, 'messages.xmb');
@ -79,4 +80,9 @@ describe('template i18n extraction output', () => {
const xlf = fs.readFileSync(xlfOutput, {encoding: 'utf-8'});
expect(xlf).toEqual(EXPECTED_XLIFF);
});
it('should not emit js', () => {
const genOutput = path.join(genDir, '');
expect(fs.existsSync(genOutput)).toBeFalsy();
});
});

View File

@ -0,0 +1,34 @@
{
"angularCompilerOptions": {
// For TypeScript 1.8, we have to lay out generated files
// in the same source directory with your code.
"genDir": ".",
"debug": true
},
"compilerOptions": {
"target": "es5",
"experimentalDecorators": true,
"noImplicitAny": true,
"moduleResolution": "node",
"outDir": "./out",
"rootDir": "",
"declaration": true,
"lib": ["es6", "dom"],
"baseUrl": ".",
// Prevent scanning up the directory tree for types
"typeRoots": ["node_modules/@types"]
},
"files": [
"src/module",
"src/bootstrap",
"test/all_spec",
"test/test_ngtools_api",
"test/test_summaries",
"benchmarks/src/tree/ng2/index_aot.ts",
"benchmarks/src/tree/ng2_switch/index_aot.ts",
"benchmarks/src/largetable/ng2/index_aot.ts",
"benchmarks/src/largetable/ng2_switch/index_aot.ts"
]
}

View File

@ -30,7 +30,7 @@ if (require.main === module) {
const args = require('minimist')(process.argv.slice(2));
const project = args.p || args.project || '.';
const cliOptions = new tsc.I18nExtractionCliOptions(args);
tsc.main(project, cliOptions, extract)
tsc.main(project, cliOptions, extract, {noEmit: true})
.then((exitCode: any) => process.exit(exitCode))
.catch((e: any) => {
console.error(e.stack);

View File

@ -48,8 +48,8 @@ cp -v package.json $TMP
./node_modules/.bin/ngc -p tsconfig-build.json --i18nFile=src/messages.fi.xlf --locale=fi --i18nFormat=xlf
./node_modules/.bin/ng-xi18n -p tsconfig-build.json --i18nFormat=xlf
./node_modules/.bin/ng-xi18n -p tsconfig-build.json --i18nFormat=xmb
./node_modules/.bin/ng-xi18n -p tsconfig-xi18n.json --i18nFormat=xlf
./node_modules/.bin/ng-xi18n -p tsconfig-xi18n.json --i18nFormat=xmb
node test/test_summaries.js
node test/test_ngtools_api.js
@ -80,4 +80,4 @@ cp -v package.json $TMP_2_1
./node_modules/.bin/tsc --version
node ./node_modules/@angular/tsc-wrapped/src/main -p third_party_src/tsconfig-build.json
./node_modules/.bin/ngc -p tsconfig-build.json --i18nFile=src/messages.fi.xlf --locale=fi --i18nFormat=xlf
)
)