Skip to content

Commit

Permalink
chore: Simplify Babel config, inlining it Jest config
Browse files Browse the repository at this point in the history
  • Loading branch information
eemeli committed Sep 3, 2024
1 parent 4c30eb6 commit 29293c4
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 39 deletions.
22 changes: 0 additions & 22 deletions config/babel.config.js

This file was deleted.

31 changes: 19 additions & 12 deletions config/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
let moduleNameMapper

const babel = [
'babel-jest',
{
overrides: [
{
test: '**/*.ts',
plugins: [
['@babel/plugin-transform-typescript', { allowDeclareFields: true }]
]
}
],
presets: [['@babel/env', { targets: { node: 'current' } }]]
}
]

const transform = {
'[/\\\\]tests[/\\\\].*\\.(m?js|ts)$': [
'babel-jest',
{ configFile: './config/babel.config.js' }
]
'[/\\\\]tests[/\\\\].*\\.(m?js|ts)$': babel
}

// The npm script name is significant.
Expand All @@ -16,10 +29,7 @@ switch (process.env.npm_lifecycle_event) {
'^yaml/util$': '<rootDir>/dist/util.js',
'^../src/test-events$': '<rootDir>/dist/test-events.js'
}
transform['[/\\\\]dist[/\\\\].*\\.mjs$'] = [
'babel-jest',
{ configFile: './config/babel.config.js' }
]
transform['[/\\\\]dist[/\\\\].*\\.mjs$'] = babel
break

case 'test':
Expand All @@ -30,10 +40,7 @@ switch (process.env.npm_lifecycle_event) {
'^yaml/cli$': '<rootDir>/src/cli.ts',
'^yaml/util$': '<rootDir>/src/util.ts'
}
transform['[/\\\\]src[/\\\\].*\\.ts$'] = [
'babel-jest',
{ configFile: './config/babel.config.js' }
]
transform['[/\\\\]src[/\\\\].*\\.ts$'] = babel
}

module.exports = {
Expand Down
1 change: 0 additions & 1 deletion config/rollup.browser-config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export default {
}),
babel({
babelHelpers: 'bundled',
configFile: './config/babel.config.js',
presets: [['@babel/env', { modules: false }]]
}),
typescript({ declaration: false, outDir: 'browser/dist' })
Expand Down
2 changes: 0 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@
},
"devDependencies": {
"@babel/core": "^7.12.10",
"@babel/plugin-transform-class-properties": "^7.23.3",
"@babel/plugin-transform-nullish-coalescing-operator": "^7.23.4",
"@babel/plugin-transform-typescript": "^7.12.17",
"@babel/preset-env": "^7.12.11",
"@eslint/js": "^9.9.1",
Expand Down

0 comments on commit 29293c4

Please sign in to comment.