In my case, I use it to bundle CLI app that use oclif which also act (and can be used) as a library.
npm i -D globby
import {sync as glob} from "globby"
const mapInput = inputs => {
const result = {}
for (const key in inputs) {
if (!key.includes('*')) Object.assign(result, {[key]: inputs[key]})
else { // support glob pattern
const [prefix, suffix] = key.split('*')
const input = glob(inputs[key]).reduce(
(obj, item) => (obj[`${prefix}/${parse(item).name}${suffix}`] = item, obj), {}
)
Object.assign(result, input)
}
}
return result
}
export default {
input: mapInput({
index: "src/index.ts",
"commands/*": "src/commands/*.ts",
"mocks/*.spec": "src/mocker/*.ts"
}),
output: {
dir: dirname(pkg.main),
chunkFileNames: "chunks/[name]-[hash].js",
format: "cjs",
exports: "named"
},
experimentalCodeSplitting: true
}