-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbabel.config.js
More file actions
20 lines (18 loc) · 902 Bytes
/
babel.config.js
File metadata and controls
20 lines (18 loc) · 902 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
const { resolve } = require('node:path')
const { readFileSync } = require('node:fs')
// NOTE: hack to load ES module in sync mode
const sourceScriptString = String(readFileSync(resolve(__dirname, './source/babel.js')))
module.exports = eval([ // eslint-disable-line no-eval
sourceScriptString.split('// HACK: @MARK_REPO_SYNC_IMPORT')[ 0 ],
'getBabelConfig()'
].join(';\n'))
// NOTE: do not support function in config
// const { runSync } = require('@dr-js/core/library/node/run.js')
// module.exports = JSON.parse(String( // NOTE: hack to load ES module in sync mode
// runSync([
// process.execPath, // node
// '--input-type=module', // https://nodejs.org/api/packages.html#packages_determining_module_system
// '--eval',
// `${String(readFileSync(resolve(__dirname, './source/babel.js')))}; console.log(JSON.stringify(getBabelConfig()))`
// ], { quiet: true }).stdout
// ))