mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 04:41:36 +08:00
Merge pull request #1039 from NativeScript/hdeshev/tsconfig-json
Compile TypeScript via a tsconfig.json file
This commit is contained in:
62
gruntfile.js
62
gruntfile.js
@ -1,3 +1,5 @@
|
|||||||
|
var tsconfig = require('./tsconfig.json');
|
||||||
|
|
||||||
module.exports = function(grunt) {
|
module.exports = function(grunt) {
|
||||||
|
|
||||||
if (grunt.cli.tasks.indexOf("testsapp") >= 0 || grunt.cli.tasks.indexOf("buildTestsApp")>= 0) {
|
if (grunt.cli.tasks.indexOf("testsapp") >= 0 || grunt.cli.tasks.indexOf("buildTestsApp")>= 0) {
|
||||||
@ -127,7 +129,7 @@ module.exports = function(grunt) {
|
|||||||
srcAppsDir: "./apps",
|
srcAppsDir: "./apps",
|
||||||
packageJsonFilePath: "./package.json",
|
packageJsonFilePath: "./package.json",
|
||||||
outDir: "./bin/dist",
|
outDir: "./bin/dist",
|
||||||
outModulesDir: "./bin/dist/modules",
|
outModulesDir: tsconfig.compilerOptions.outDir,
|
||||||
outAppsDir: "./bin/dist/apps",
|
outAppsDir: "./bin/dist/apps",
|
||||||
outTsAppsDir: "./bin/dist/ts-apps",
|
outTsAppsDir: "./bin/dist/ts-apps",
|
||||||
};
|
};
|
||||||
@ -141,37 +143,18 @@ module.exports = function(grunt) {
|
|||||||
localCfg.mainPackageContent = grunt.file.readJSON(localCfg.packageJsonFilePath);
|
localCfg.mainPackageContent = grunt.file.readJSON(localCfg.packageJsonFilePath);
|
||||||
localCfg.packageVersion = getPackageVersion(localCfg.packageJsonFilePath);
|
localCfg.packageVersion = getPackageVersion(localCfg.packageJsonFilePath);
|
||||||
localCfg.commitSHA = getCommitSha();
|
localCfg.commitSHA = getCommitSha();
|
||||||
localCfg.defaultExcludes = [
|
localCfg.typeScriptSrc = tsconfig.filesGlob;
|
||||||
"!" + localCfg.outDir + "/**/*.*",
|
localCfg.defaultExcludes = localCfg.typeScriptSrc.filter(function(item) { return /^!/.test(item); });
|
||||||
"!./node_modules/**/*.*",
|
|
||||||
"!./bin/**/*.*",
|
|
||||||
"!./build/**/*.*",
|
|
||||||
"!./Deploy/**/*.*",
|
|
||||||
"!./obj/**/*.*",
|
|
||||||
"!./out/**/*.*",
|
|
||||||
"!./.*/**/*.*"
|
|
||||||
];
|
|
||||||
localCfg.typeScriptSrc = [
|
|
||||||
"./**/*.ts"
|
|
||||||
].concat(localCfg.defaultExcludes);
|
|
||||||
localCfg.typeScriptSrcForTsLint = localCfg.typeScriptSrc.concat([
|
localCfg.typeScriptSrcForTsLint = localCfg.typeScriptSrc.concat([
|
||||||
"!./ios.d.ts",
|
"!ios.d.ts",
|
||||||
"!./android17.d.ts",
|
"!android17.d.ts",
|
||||||
"!./libjs.d.ts"
|
"!libjs.d.ts"
|
||||||
]);
|
]);
|
||||||
|
|
||||||
var tsOptions = {
|
var tsOptions = tsconfig.compilerOptions;
|
||||||
fast: 'never',
|
tsOptions.fast = 'never';
|
||||||
module: "commonjs",
|
tsOptions.removeComments = !grunt.option('leavecomments') || '';
|
||||||
target: "es5",
|
tsOptions.compiler = "node_modules/typescript/bin/tsc";
|
||||||
sourceMap: false,
|
|
||||||
declaration: false,
|
|
||||||
removeComments: !grunt.option('leavecomments') || '',
|
|
||||||
compiler: "node_modules/typescript/bin/tsc",
|
|
||||||
noEmitOnError: true,
|
|
||||||
experimentalDecorators: true,
|
|
||||||
noEmitHelpers: true
|
|
||||||
};
|
|
||||||
|
|
||||||
grunt.initConfig({
|
grunt.initConfig({
|
||||||
localCfg : localCfg,
|
localCfg : localCfg,
|
||||||
@ -183,9 +166,9 @@ module.exports = function(grunt) {
|
|||||||
typeScriptLeftovers: {
|
typeScriptLeftovers: {
|
||||||
expand: true,
|
expand: true,
|
||||||
src: [
|
src: [
|
||||||
"./.baseDir.*",
|
".baseDir.*",
|
||||||
"./_references.js",
|
"_references.js",
|
||||||
"./**/*.map"
|
"**/*.map"
|
||||||
],
|
],
|
||||||
cwd: localCfg.outModulesDir
|
cwd: localCfg.outModulesDir
|
||||||
},
|
},
|
||||||
@ -306,7 +289,7 @@ module.exports = function(grunt) {
|
|||||||
},
|
},
|
||||||
ts: {
|
ts: {
|
||||||
build: {
|
build: {
|
||||||
src: localCfg.typeScriptSrc,
|
tsconfig: 'tsconfig.json',
|
||||||
outDir: localCfg.outModulesDir,
|
outDir: localCfg.outModulesDir,
|
||||||
options: tsOptions
|
options: tsOptions
|
||||||
},
|
},
|
||||||
@ -503,8 +486,11 @@ module.exports = function(grunt) {
|
|||||||
"copy:readyTsAppFiles"
|
"copy:readyTsAppFiles"
|
||||||
]);
|
]);
|
||||||
grunt.registerTask("generate-tns-core-modules-dts", function() {
|
grunt.registerTask("generate-tns-core-modules-dts", function() {
|
||||||
var dtsFiles = grunt.file.expand({cwd: localCfg.outModulesDir}, ['**/*.d.ts']);
|
var dtsFiles = grunt.file.expand({cwd: localCfg.outModulesDir}, [
|
||||||
dtsFiles.sort()
|
'**/*.d.ts',
|
||||||
|
'!tns-core-modules.d.ts'
|
||||||
|
].concat(localCfg.defaultExcludes));
|
||||||
|
dtsFiles.sort();
|
||||||
|
|
||||||
var dtsLines = dtsFiles.map(function(dtsFile) {
|
var dtsLines = dtsFiles.map(function(dtsFile) {
|
||||||
return '/// <reference path="' + dtsFile + '" />';
|
return '/// <reference path="' + dtsFile + '" />';
|
||||||
@ -554,12 +540,6 @@ module.exports = function(grunt) {
|
|||||||
"pack-modules"
|
"pack-modules"
|
||||||
]));
|
]));
|
||||||
|
|
||||||
grunt.registerTask("testEnv", function() {
|
|
||||||
console.log('fafla', process.env.NODE_PATH);
|
|
||||||
//var x = require('xml')
|
|
||||||
//console.log(x);
|
|
||||||
});
|
|
||||||
|
|
||||||
grunt.registerTask("node-tests", [
|
grunt.registerTask("node-tests", [
|
||||||
"clean:nodeTests",
|
"clean:nodeTests",
|
||||||
"ts:buildNodeTests",
|
"ts:buildNodeTests",
|
||||||
|
1160
tsconfig.json
1160
tsconfig.json
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user