From 634f4cd1a9c184f1567505772068caf9920e1dc2 Mon Sep 17 00:00:00 2001 From: Christopher Wallis Date: Tue, 18 Oct 2016 01:36:38 -0400 Subject: [PATCH 1/4] tsconfig path can be passed in the tsconfig option --- src/index.js | 7 +++++-- src/options.js | 4 ++-- test/sample/custom-tsconfig/main.ts | 2 ++ test/sample/custom-tsconfig/tsconfig.json | 5 +++++ test/test.js | 8 ++++++++ 5 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 test/sample/custom-tsconfig/main.ts create mode 100644 test/sample/custom-tsconfig/tsconfig.json diff --git a/src/index.js b/src/index.js index 425b3c2..c839599 100644 --- a/src/index.js +++ b/src/index.js @@ -40,8 +40,11 @@ export default function typescript ( options ) { delete options.typescript; // Load options from `tsconfig.json` unless explicitly asked not to. - const tsconfig = options.tsconfig === false ? {} : - compilerOptionsFromTsConfig( typescript ); + const tsconfig = options.tsconfig === false + ? {} + : typeof options.tsconfig === 'string' + ? compilerOptionsFromTsConfig(typescript, options.tsconfig) + : compilerOptionsFromTsConfig(typescript, 'tsconfig.json'); delete options.tsconfig; diff --git a/src/options.js b/src/options.js index 5502ba4..e1b6ac3 100644 --- a/src/options.js +++ b/src/options.js @@ -37,10 +37,10 @@ function findFile ( cwd, filename ) { return null; } -export function compilerOptionsFromTsConfig ( typescript ) { +export function compilerOptionsFromTsConfig ( typescript, filename) { const cwd = process.cwd(); - const tsconfig = typescript.readConfigFile( findFile( cwd, 'tsconfig.json' ), path => readFileSync( path, 'utf8' ) ); + const tsconfig = typescript.readConfigFile( findFile( cwd, filename ), path => readFileSync( path, 'utf8' ) ); if ( !tsconfig.config || !tsconfig.config.compilerOptions ) return {}; diff --git a/test/sample/custom-tsconfig/main.ts b/test/sample/custom-tsconfig/main.ts new file mode 100644 index 0000000..d0b587a --- /dev/null +++ b/test/sample/custom-tsconfig/main.ts @@ -0,0 +1,2 @@ +const answer: number = 42; +console.log( `the answer is ${answer}` ); diff --git a/test/sample/custom-tsconfig/tsconfig.json b/test/sample/custom-tsconfig/tsconfig.json new file mode 100644 index 0000000..ea71f94 --- /dev/null +++ b/test/sample/custom-tsconfig/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "target": "es6" + } +} \ No newline at end of file diff --git a/test/test.js b/test/test.js index 9bcd97c..2e8a98c 100644 --- a/test/test.js +++ b/test/test.js @@ -220,6 +220,14 @@ describe( 'rollup-plugin-typescript', function () { assert.ok( map.sources.every( source => source.indexOf( 'typescript-helpers' ) === -1) ); }); }); + + it( 'reads in custom tsconfig files', () => { + return bundle('sample/custom-tsconfig/main.ts', { + tsconfig: 'sample/custom-tsconfig/tsconfig.json' + }).then(bundle => { + assert.equal(bundle.modules[1].code.indexOf('const answer = 42'), 0); + }); + }); }); function fakeTypescript ( custom ) { From 27b78a06f5afb696e4fd607f48543993e6a7dbe2 Mon Sep 17 00:00:00 2001 From: Christopher Wallis Date: Thu, 12 Jan 2017 16:01:14 -0500 Subject: [PATCH 2/4] updated to 2.1.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0d6b857..73f570e 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "object-assign": "^4.0.1", "rollup-pluginutils": "^1.3.1", "tippex": "^2.1.1", - "typescript": "^1.8.9" + "typescript": "^2.1.4" }, "devDependencies": { "buble": "^0.13.1", From 1f48874ccf56b92a102c6c6f19df6ddf6416d8ee Mon Sep 17 00:00:00 2001 From: Christopher Wallis Date: Tue, 23 May 2017 02:38:36 -0400 Subject: [PATCH 3/4] reverse last commit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 73f570e..0d6b857 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "object-assign": "^4.0.1", "rollup-pluginutils": "^1.3.1", "tippex": "^2.1.1", - "typescript": "^2.1.4" + "typescript": "^1.8.9" }, "devDependencies": { "buble": "^0.13.1", From 987402056c85005963760be0e805d063e9284287 Mon Sep 17 00:00:00 2001 From: Christopher Wallis Date: Tue, 23 May 2017 02:57:19 -0400 Subject: [PATCH 4/4] forcing a commit to kick off travis after PR target change --- test/sample/custom-tsconfig/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sample/custom-tsconfig/tsconfig.json b/test/sample/custom-tsconfig/tsconfig.json index ea71f94..02fe94c 100644 --- a/test/sample/custom-tsconfig/tsconfig.json +++ b/test/sample/custom-tsconfig/tsconfig.json @@ -1,5 +1,5 @@ { "compilerOptions": { - "target": "es6" + "target": "es6" } } \ No newline at end of file