Skip to content

Commit 6512b46

Browse files
jakegavinjaredpalmer
authored andcommitted
Explicitly specify ts and tsx extensions in babel options (#96)
* fix: explicitly specify ts and tsx extensions in babel options rollup-plugin-typescript2 transpiles the code but doesn't change the file extensions. Files with ts and tsx extentions aren't processed by Babel by default so we need to add those extensions to the babel config. * Patch/extend @babel/core types
1 parent 517b8fa commit 6512b46

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/createRollupConfig.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { DEFAULT_EXTENSIONS } from '@babel/core';
12
import { safeVariableName, safePackageName, external } from './utils';
23
import { paths } from './constants';
34
import { terser } from 'rollup-plugin-terser';
@@ -14,6 +15,7 @@ const replacements = [{ original: 'lodash', replacement: 'lodash-es' }];
1415

1516
const babelOptions = {
1617
exclude: /node_modules/,
18+
extensions: [...DEFAULT_EXTENSIONS, 'ts', 'tsx'],
1719
plugins: [
1820
'annotate-pure-calls',
1921
'dev-expression',

src/env.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ declare module 'ora';
55
declare module 'sade';
66
declare module 'tiny-glob/sync';
77
declare module 'ansi-escapes';
8+
9+
// Patch Babel
10+
// @see line 226 of https://unpkg.com/@babel/core@7.4.4/lib/index.js
11+
declare module '@babel/core' {
12+
export const DEFAULT_EXTENSIONS: string[];
13+
}
14+
815
// Rollup plugins
916
declare module '@jaredpalmer/rollup-plugin-preserve-shebang';
1017
declare module 'rollup-plugin-babel';

0 commit comments

Comments
 (0)