unbuild
unbuild copied to clipboard
feat: support jiti babel plugins config in stubOptions
โ Type of change
- [ ] ๐ Documentation (updates to the documentation, readme, or JSdoc annotations)
- [ ] ๐ Bug fix (a non-breaking change that fixes an issue)
- [ ] ๐ Enhancement (improving an existing functionality like performance)
- [x] โจ New feature (a non-breaking change that adds functionality)
- [ ] ๐งน Chore (updates to the build process or auxiliary tools and libraries)
- [ ] โ ๏ธ Breaking change (fix or feature that would cause existing functionality to change)
๐ Description
build.config.ts
{
stubOptions: {
jiti: {
transformOptions: {
babel: {
plugins: [
["@babel/plugin-transform-class-properties"],
],
},
},
},
},
}
run unbuild --stub
index.cjs
const jiti = require("xxx/node_modules/.pnpm/[email protected]/node_modules/jiti/lib/index.js")
const plugin0 = require("@babel/plugin-transform-class-properties")
const _jiti = jiti(null, {
"esmResolve": true,
"interopDefault": true,
"alias": {
"fixture": "xxx/test/fixture"
},
"transformOptions": {
"babel": {
"plugins": [[plugin0]]
}
}
})
/** @type {import("xxx/test/fixture/src/index")} */
module.exports = _jiti("xxx/test/fixture/src/index.ts")
index.mjs
import jiti from "xxx/node_modules/.pnpm/[email protected]/node_modules/jiti/lib/index.js";
import plugin0 from "@babel/plugin-transform-class-properties"
const _jiti = jiti(null, {
"esmResolve": true,
"interopDefault": true,
"alias": {
"fixture": "xxx/test/fixture"
},
"transformOptions": {
"babel": {
"plugins": [[plugin0]]
}
}
})
/** @type {import("xxx/test/fixture/src/index")} */
const _module = await _jiti.import("xxx/test/fixture/src/index.ts");
export default _module;
export const foo = _module.foo;
export const baz = _module.baz;
๐ Checklist
- [ ] I have linked an issue or discussion.
- [ ] I have updated the documentation accordingly.