diff --git a/package.json b/package.json index ae930b8..6750a15 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@babel/polyfill": "^7.0.0", "asyncro": "^3.0.0", "autoprefixer": "^9.0.0", - "babel-plugin-transform-async-to-promises": "^0.8.1", + "babel-plugin-transform-async-to-promises": "^0.8.3", "brotli-size": "^0.0.3", "camelcase": "^5.0.0", "chalk": "^2.4.0", diff --git a/src/index.js b/src/index.js index 950aa9d..a9ef3f0 100644 --- a/src/index.js +++ b/src/index.js @@ -372,7 +372,7 @@ function createConfig(options, entry, format, writeMeta) { }, tsconfigOverride: { compilerOptions: { - target: 'es2017', + target: 'esnext', }, }, }), @@ -384,6 +384,7 @@ function createConfig(options, entry, format, writeMeta) { // supplied configurations we set this option to false. Note // that we never supported using custom babel configs anyway. babelrc: false, + extensions: ['.ts', '.tsx', '.js', '.jsx', '.es6', '.es', '.mjs'], exclude: 'node_modules/**', plugins: [ require.resolve('@babel/plugin-syntax-jsx'), diff --git a/test/__snapshots__/index.test.js.snap b/test/__snapshots__/index.test.js.snap index 91a3818..7abcf94 100644 --- a/test/__snapshots__/index.test.js.snap +++ b/test/__snapshots__/index.test.js.snap @@ -1,5 +1,63 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`fixtures async-iife-ts 1`] = ` +"Used script: microbundle + +Directory tree: + +async-iife-ts + dist + async-iife-ts.js + async-iife-ts.js.map + async-iife-ts.mjs + async-iife-ts.mjs.map + async-iife-ts.umd.js + async-iife-ts.umd.js.map + index.d.ts + package.json + src + index.ts + tsconfig.json + + +Build \\"asyncIifeTs\\" to dist: +93 B: async-iife-ts.js.gz +74 B: async-iife-ts.js.br +93 B: async-iife-ts.mjs.gz +74 B: async-iife-ts.mjs.br +164 B: async-iife-ts.umd.js.gz +123 B: async-iife-ts.umd.js.br" +`; + +exports[`fixtures async-ts 1`] = ` +"Used script: microbundle + +Directory tree: + +async-ts + dist + async-ts.js + async-ts.js.map + async-ts.mjs + async-ts.mjs.map + async-ts.umd.js + async-ts.umd.js.map + index.d.ts + package.json + src + index.ts + tsconfig.json + + +Build \\"asyncTs\\" to dist: +158 B: async-ts.js.gz +122 B: async-ts.js.br +160 B: async-ts.mjs.gz +128 B: async-ts.mjs.br +245 B: async-ts.umd.js.gz +202 B: async-ts.umd.js.br" +`; + exports[`fixtures basic 1`] = ` "Used script: microbundle @@ -310,12 +368,12 @@ esnext-ts Build \\"esnextTs\\" to dist: -470 B: esnext-ts.js.gz -404 B: esnext-ts.js.br -470 B: esnext-ts.mjs.gz -409 B: esnext-ts.mjs.br -528 B: esnext-ts.umd.js.gz -461 B: esnext-ts.umd.js.br" +841 B: esnext-ts.js.gz +753 B: esnext-ts.js.br +842 B: esnext-ts.mjs.gz +751 B: esnext-ts.mjs.br +902 B: esnext-ts.umd.js.gz +804 B: esnext-ts.umd.js.br" `; exports[`fixtures jsx 1`] = ` diff --git a/test/fixtures/async-iife-ts/package.json b/test/fixtures/async-iife-ts/package.json new file mode 100644 index 0000000..196e228 --- /dev/null +++ b/test/fixtures/async-iife-ts/package.json @@ -0,0 +1,3 @@ +{ + "name": "async-iife-ts" +} diff --git a/test/fixtures/async-iife-ts/src/index.ts b/test/fixtures/async-iife-ts/src/index.ts new file mode 100644 index 0000000..863d5c5 --- /dev/null +++ b/test/fixtures/async-iife-ts/src/index.ts @@ -0,0 +1,3 @@ +(async function() { + console.log('foo'); +})(); diff --git a/test/fixtures/async-iife-ts/tsconfig.json b/test/fixtures/async-iife-ts/tsconfig.json new file mode 100644 index 0000000..265086f --- /dev/null +++ b/test/fixtures/async-iife-ts/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "rootDir": "./src" + } +} diff --git a/test/fixtures/async-ts/package.json b/test/fixtures/async-ts/package.json new file mode 100644 index 0000000..484645c --- /dev/null +++ b/test/fixtures/async-ts/package.json @@ -0,0 +1,3 @@ +{ + "name": "async-ts" +} diff --git a/test/fixtures/async-ts/src/index.ts b/test/fixtures/async-ts/src/index.ts new file mode 100644 index 0000000..3098a3a --- /dev/null +++ b/test/fixtures/async-ts/src/index.ts @@ -0,0 +1,3 @@ +export class MyClass { + async foo() {} +} diff --git a/test/fixtures/async-ts/tsconfig.json b/test/fixtures/async-ts/tsconfig.json new file mode 100644 index 0000000..265086f --- /dev/null +++ b/test/fixtures/async-ts/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "rootDir": "./src" + } +} diff --git a/test/fixtures/esnext-ts/src/index.ts b/test/fixtures/esnext-ts/src/index.ts index 057955a..2816430 100644 --- a/test/fixtures/esnext-ts/src/index.ts +++ b/test/fixtures/esnext-ts/src/index.ts @@ -1,10 +1,10 @@ export default async function foo() { const out = []; - for await (const item of [1,2]) { + for await (const item of [1, 2]) { out.push(item); } return out; } -foo().then(console.log) +foo().then(console.log);