-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtsx.js
More file actions
31 lines (25 loc) · 1.1 KB
/
tsx.js
File metadata and controls
31 lines (25 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**
* Copyright 2020 Erik Isaksson
* Released under MIT license, https://github.com/erikis/require-babel/blob/master/LICENSE
*/
/*global define */
define(['module', 'require-babel'], function (module, babel) {
'use strict';
var pluginConfig = module.config ? module.config() : {};
pluginConfig.extension = pluginConfig.extension || '.tsx';
pluginConfig.extensions = pluginConfig.extensions || { '.ts': 'tsm!', '.tsx': 'tsx!' };
var options = pluginConfig.options = pluginConfig.options || {};
var presets = babel.defaultPresets.slice();
presets.push([ 'react', pluginConfig.react || {} ]);
presets.push([ 'typescript', pluginConfig.typescript || { allExtensions: true, isTSX: true } ]);
options.presets = options.presets || presets;
return {
version: babel.version,
write: function (pluginName, name, write) {
return babel.write.call(babel, pluginName, name, write);
},
load: function (name, parentRequire, load, config) {
return babel.load.call(babel, name, parentRequire, load, config, pluginConfig);
}
};
});