@vitus-labs/tools-rollup
v2.3.0
Published
[Rollup](https://rollupjs.org)-powered build tool for TypeScript libraries.
Downloads
1,761
Readme
@vitus-labs/tools-rollup
Rollup-powered build tool for TypeScript libraries.
Supports multi-platform, multi-format builds with TypeScript declaration bundling via Microsoft API Extractor.
Installation
bun add -d @vitus-labs/tools-rollupUsage
Add to your package.json:
{
"scripts": {
"build": "vl_build",
"dev": "vl_build-watch"
}
}How it works
The build tool reads your package.json to determine what output bundles to produce:
| package.json field | Format | Platform |
|---|---|---|
| exports.import | ESM | universal |
| exports.require | CJS | universal |
| main | CJS or ESM | universal |
| module | ESM | universal |
| browser | same as source | browser |
| react-native | ESM | native |
| umd:main | UMD | — |
| unpkg | UMD (minified) | — |
TypeScript declarations are bundled into a single .d.ts file using API Extractor when exports.types (or types/typings) is set.
Platform globals
These constants are injected at build time based on the output platform:
| Constant | Description |
|---|---|
| __VERSION__ | Package version from package.json |
| __BROWSER__ | true for browser builds |
| __NODE__ | true for node builds |
| __WEB__ | true for node + browser + universal |
| __NATIVE__ | true for React Native builds |
| __CLIENT__ | true for browser + native |
Add type declarations to your project:
{
"compilerOptions": {
"types": ["@vitus-labs/tools-rollup/global"]
}
}Configuration
Configure via vl-tools.config.mjs (key: build):
export default {
build: {
sourceDir: 'src',
outputDir: 'lib',
typescript: true,
esModulesOnly: false,
replaceGlobals: true,
external: ['react/jsx-runtime'],
globals: {
react: 'React',
'react-dom': 'ReactDOM',
},
},
}License
MIT
