1 | // @flow
|
2 | import path from 'path';
|
3 |
|
4 | import type {Config} from '@parcel/types';
|
5 | import type {BabelConfig} from './types';
|
6 |
|
7 | export default function getTypescriptOptions(
|
8 | config: Config,
|
9 | pragma: ?string,
|
10 | pragmaFrag: ?string,
|
11 | ): BabelConfig {
|
12 | return {
|
13 | plugins: [
|
14 | [
|
15 | '@babel/plugin-transform-typescript',
|
16 | {
|
17 | isTSX: path.extname(config.searchPath) === '.tsx',
|
18 | // Needed because of https://github.com/babel/babel/issues/12585
|
19 | jsxPragma: pragma,
|
20 | jsxPragmaFrag: pragmaFrag,
|
21 | },
|
22 | ],
|
23 | ],
|
24 | };
|
25 | }
|