Make file extension handling consistent
Update the extensions that @babel/register hooks and that the babel
module resolver plugin resolves to be the default set imported from
@babel/core augmented with TypeScript extensions.
diff --git a/.eslintrc.js b/.eslintrc.js
index 63c7c38..165813d 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -32,13 +32,7 @@
extends: ['eslint:recommended', 'plugin:import/recommended', 'prettier'],
plugins: ['import', 'prettier'],
rules: {
- 'import/extensions': [
- 'error',
- 'ignorePackages',
- {
- ts: 'never',
- },
- ],
+ 'import/extensions': ['error', 'never'],
'import/first': 'error',
'import/newline-after-import': 'error',
'import/no-absolute-path': 'error',
diff --git a/babel-register.js b/babel-register.js
index ec45b5b..6ae0a76 100644
--- a/babel-register.js
+++ b/babel-register.js
@@ -18,4 +18,7 @@
* under the License.
*/
-require('@babel/register')({ extensions: ['.ts'] });
+const { DEFAULT_EXTENSIONS } = require('@babel/core');
+require('@babel/register')({
+ extensions: ['.ts', '.tsx', ...DEFAULT_EXTENSIONS],
+});
diff --git a/babel.config.js b/babel.config.js
index 61a7186..8e5e5a3 100644
--- a/babel.config.js
+++ b/babel.config.js
@@ -19,6 +19,7 @@
*/
const path = require('path');
+const { DEFAULT_EXTENSIONS } = require('@babel/core');
module.exports = (api) => {
const ENV = api.env();
@@ -70,8 +71,8 @@
'@babel/runtime-corejs3/helpers/\\1.js',
'^@babel/runtime-corejs3/regenerator$':
'@babel/runtime-corejs3/regenerator/index.js',
- extensions: ['.js', '.ts'],
},
+ extensions: ['.ts', '.tsx', ...DEFAULT_EXTENSIONS],
};
// Options for the @babel/transform-runtime plugin.