diff --git a/package.json b/package.json index ff67a3f..9521e26 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.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 fb889ee..e9c6fdc 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'; @@ -216,7 +216,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 d78674c..81b6188 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 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/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)]);