From 47ccb24d3caa62da5e59471485fc1e2976b331bb Mon Sep 17 00:00:00 2001 From: Michel Rasschaert Date: Sun, 28 Jan 2018 18:56:26 +0100 Subject: [PATCH 1/3] ignore files and folders starting with dot in the tests also switch folder to the fixture directory because some rollup plugins rely on `process.cwd()`. --- test/index.test.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/index.test.js b/test/index.test.js index c5f5826..6946534 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -12,7 +12,7 @@ const constant = konst => () => konst; const printTree = (nodes, indentLevel = 0) => { const indent = join(times(indentLevel, constant(' '))); - return join(nodes.map(node => + return join(nodes.filter(node => node.name[0] !== '.').map(node => `${indent}${node.name}\n${node.type === 'directory' ? printTree(node.children, indentLevel + 1) : ''}` )); }; @@ -26,10 +26,13 @@ describe('fixtures', () => { } it(fixtureDir, async () => { + const prevDir = process.cwd(); + process.chdir(path.resolve(fixturePath)); const output = await microbundle({ cwd: path.resolve(fixturePath), formats: 'es,cjs,umd' }); + process.chdir(prevDir); const printedDir = printTree([dirTree(fixturePath)]); From 0c8c4525752c3113d986c70a2d111e002c180c13 Mon Sep 17 00:00:00 2001 From: Michel Rasschaert Date: Sun, 28 Jan 2018 18:57:33 +0100 Subject: [PATCH 2/3] switch to rollup-plugin-typescript2 adjust test to verify generation of `.d.ts`. --- package.json | 2 +- src/index.js | 2 +- test/__snapshots__/index.test.js.snap | 3 +++ test/fixtures/ts-demo/src/car.ts | 2 +- test/fixtures/ts-demo/tsconfig.json | 5 +++++ 5 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 test/fixtures/ts-demo/tsconfig.json diff --git a/package.json b/package.json index 3473f1b..b3c3402 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "rollup-plugin-preserve-shebang": "^0.1.6", "rollup-plugin-sizes": "^0.4.2", "rollup-plugin-strict-alias": "^1.0.0", - "rollup-plugin-typescript": "^0.8.1", + "rollup-plugin-typescript2": "^0.10.0", "rollup-plugin-uglify": "^3.0.0", "sade": "^1.3.1", "tslib": "^1.9.0", diff --git a/src/index.js b/src/index.js index f9c82af..6cb6bed 100644 --- a/src/index.js +++ b/src/index.js @@ -17,7 +17,7 @@ import alias from 'rollup-plugin-strict-alias'; import gzipSize from 'gzip-size'; import prettyBytes from 'pretty-bytes'; import shebangPlugin from 'rollup-plugin-preserve-shebang'; -import typescript from 'rollup-plugin-typescript'; +import typescript from 'rollup-plugin-typescript2'; import flow from './lib/flow-plugin'; import camelCase from 'camelcase'; diff --git a/test/__snapshots__/index.test.js.snap b/test/__snapshots__/index.test.js.snap index d78674c..0f407df 100644 --- a/test/__snapshots__/index.test.js.snap +++ b/test/__snapshots__/index.test.js.snap @@ -41,6 +41,8 @@ Build output to dist: exports[`fixtures ts-demo 1`] = ` "ts-demo dist + car.d.ts + index.d.ts ts-demo.js ts-demo.js.map ts-demo.m.js @@ -50,6 +52,7 @@ exports[`fixtures ts-demo 1`] = ` src car.ts index.ts + tsconfig.json Build output to dist: diff --git a/test/fixtures/ts-demo/src/car.ts b/test/fixtures/ts-demo/src/car.ts index 4eb11a6..82d1754 100644 --- a/test/fixtures/ts-demo/src/car.ts +++ b/test/fixtures/ts-demo/src/car.ts @@ -1,4 +1,4 @@ -interface Driveable { +export interface Driveable { drive(distance: number): boolean; } diff --git a/test/fixtures/ts-demo/tsconfig.json b/test/fixtures/ts-demo/tsconfig.json new file mode 100644 index 0000000..6c9058e --- /dev/null +++ b/test/fixtures/ts-demo/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "declaration": true + } +} From 1bd22b7ab77ea4ec754004084a4f2291d7fda8d7 Mon Sep 17 00:00:00 2001 From: Michel Rasschaert Date: Fri, 2 Feb 2018 07:49:50 +0100 Subject: [PATCH 3/3] upgrade to rollup-plugin-typescript2@0.11 --- package.json | 2 +- src/index.js | 5 ++++- test/__snapshots__/index.test.js.snap | 1 - test/fixtures/ts-demo/tsconfig.json | 5 ----- 4 files changed, 5 insertions(+), 8 deletions(-) delete mode 100644 test/fixtures/ts-demo/tsconfig.json diff --git a/package.json b/package.json index b3c3402..f93718b 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "rollup-plugin-preserve-shebang": "^0.1.6", "rollup-plugin-sizes": "^0.4.2", "rollup-plugin-strict-alias": "^1.0.0", - "rollup-plugin-typescript2": "^0.10.0", + "rollup-plugin-typescript2": "^0.11", "rollup-plugin-uglify": "^3.0.0", "sade": "^1.3.1", "tslib": "^1.9.0", diff --git a/src/index.js b/src/index.js index 6cb6bed..89fcb45 100644 --- a/src/index.js +++ b/src/index.js @@ -212,7 +212,10 @@ function createConfig(options, entry, format, writeMeta) { inject: false, extract: !!writeMeta }), - useTypescript && typescript({ typescript: require('typescript') }), + useTypescript && typescript({ + typescript: require('typescript'), + tsconfigDefaults: { compilerOptions: { declaration: true } } + }), !useTypescript && flow({ all: true, pretty: true }), nodent({ exclude: 'node_modules/**', diff --git a/test/__snapshots__/index.test.js.snap b/test/__snapshots__/index.test.js.snap index 0f407df..81b6188 100644 --- a/test/__snapshots__/index.test.js.snap +++ b/test/__snapshots__/index.test.js.snap @@ -52,7 +52,6 @@ exports[`fixtures ts-demo 1`] = ` src car.ts index.ts - tsconfig.json Build output to dist: diff --git a/test/fixtures/ts-demo/tsconfig.json b/test/fixtures/ts-demo/tsconfig.json deleted file mode 100644 index 6c9058e..0000000 --- a/test/fixtures/ts-demo/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "declaration": true - } -}