diff --git a/package.json b/package.json index 9f06fec05..c274fa959 100644 --- a/package.json +++ b/package.json @@ -30,15 +30,15 @@ }, "scripts": { "precommit": "lint-staged", - "prepush": "npm run build", + "prepush": "yarn run build", "test": "jest", "test:watch": "jest --watch", "lint": "tslint \"source/**/*.ts\"", "lint:fix": "tslint \"source/**/*.ts\" --fix", - "prepublishOnly": "npm run build && yarn declarations", - "build": "shx rm -rf ./distribution && tsc && madge ./distribution --circular", + "prepublishOnly": "yarn run build && yarn declarations", + "build": "shx rm -rf ./distribution && tsc -p tsconfig.production.json && madge ./distribution --circular", "build:watch": "tsc -w", - "link": "npm run build && chmod +x distribution/commands/danger.js && npm link", + "link": "yarn run build && chmod +x distribution/commands/danger.js && npm link", "declarations": "ts-node ./scripts/create-danger-dts.ts", "docs:cp_defs": "mkdir docs/docs_generate; cp source/danger.d.ts docs/docs_generate; cp node_modules/github/lib/index.d.ts docs/docs_generate/github.d.ts", diff --git a/source/runner/DangerfileRunner.ts b/source/runner/DangerfileRunner.ts index 5b563a8e7..447159af0 100644 --- a/source/runner/DangerfileRunner.ts +++ b/source/runner/DangerfileRunner.ts @@ -167,7 +167,8 @@ export function cleanDangerfile(contents: string): string { const typescriptify = (content: string): string => { const ts = require("typescript") // tslint:disable-line - let result = ts.transpileModule(content, {}) + const compilerOptions = JSON.parse(fs.readFileSync("tsconfig.json", "utf8")) + let result = ts.transpileModule(content, compilerOptions) return result.outputText } diff --git a/tsconfig.json b/tsconfig.json index af915551a..b9c93977b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,9 +14,9 @@ "module": "commonjs", "moduleResolution": "node", "pretty": true, - "target": "es2015", + "target": "es5", "outDir": "distribution", - "lib": ["es5", "es2017"] + "lib": ["es2017"] }, "formatCodeOptions": { "indentSize": 2, diff --git a/tsconfig.production.json b/tsconfig.production.json new file mode 100644 index 000000000..c66c485dc --- /dev/null +++ b/tsconfig.production.json @@ -0,0 +1,12 @@ +{ + "extends": "./tsconfig.json", + "exclude": [ + "dangerfile.ts", + "scripts", + "node_modules", + "source/**/fixtures/*", + "source/**/_tests/*", + "distribution", + "types" + ] +}