Skip to content

Commit

Permalink
Convert babel config from JSON to JavaScript ☕️ (#4)
Browse files Browse the repository at this point in the history
* Convert babel config from JSON to JavaScript ☕️

* Update moduleNameMapper to support multiple files 🗺️

* Change babel config extension to cjs 🛻
  • Loading branch information
01taylop authored Jun 8, 2024
1 parent 02c3c83 commit cd8f01a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 23 deletions.
19 changes: 19 additions & 0 deletions babel.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
presets: [
["@babel/preset-env", { targets: { node: "current" } }],
],
env: {
cjs: {
presets: [["@babel/preset-env", { modules: "commonjs" }]],
plugins: [
["babel-plugin-add-import-extension", { extension: "cjs" }],
],
},
esm: {
presets: [["@babel/preset-env", { modules: false }]],
plugins: [
["babel-plugin-add-import-extension", { extension: "js" }],
],
},
},
}
19 changes: 0 additions & 19 deletions babel.config.json

This file was deleted.

3 changes: 1 addition & 2 deletions jest/cjs.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import baseConfig from '../jest.config.js'
export default {
...baseConfig,
moduleNameMapper: {
'<rootDir>/src/config$': '<rootDir>/lib/config.cjs',
'<rootDir>/src/index$': '<rootDir>/lib/index.cjs',
'<rootDir>/src/(.*)$': '<rootDir>/lib/$1.cjs',
},
rootDir: '../',
}
3 changes: 1 addition & 2 deletions jest/esm.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import baseConfig from '../jest.config.js'
export default {
...baseConfig,
moduleNameMapper: {
'<rootDir>/src/config$': '<rootDir>/lib/config.js',
'<rootDir>/src/index$': '<rootDir>/lib/index.js',
'<rootDir>/src/(.*)$': '<rootDir>/lib/$1.js',
},
rootDir: '../',
}

0 comments on commit cd8f01a

Please sign in to comment.