📦 Universal JavaScript library bundler, powered by Rollup.
npm install @surmon-china/libundler --save-dev
You can also use yarn
or pnpm
.
"scripts": {
"build": "libundler"
}
You can also use the command b
.
yarn build
By default, you do not need to specify configuration file, libundler will generate a nearly perfect configuration for the bundle according to your package.json
.
But if you have more specific needs, you can create libundler.config.js
or libundler.config.ts
in your project root.
LibundlerConfigObject
LibundlerConfigObject[]
(defaultRollupConfig) => RollupConfig
config example projects:
- javascript nope config
- javascript
cjs
format config - javascript
esm
format config - typescript
- react-jsx-scss
- react-tsx
object config example:
// libundler.config.js
/** @type {import('@surmon-china/libundler/lib/interface').LibundlerConfigObject} */
module.exports = {
entry: 'src/index.js',
// ...
}
array config example:
// libundler.config.js
/** @type {import('@surmon-china/libundler/lib/interface').LibundlerConfigArray} */
module.exports = [
{
entry: 'src/index.ts',
// ...
},
{
entry: 'src/entry.ts',
// ...
},
]
function config example:
// libundler.config.js
/** @type {import('@surmon-china/libundler/lib/interface').LibundlerConfigFn} */
module.exports = (rollupConfig) => {
// overwrite the Rollup config
rollupConfig.plugins.push(/* ... */)
// ...
return rollupConfig
}
esm
config example:
// libundler.config.js
export default {
entry: 'src/index.js',
// ...
}
.ts
config example:
// libundler.config.ts
import { defineConfig } from '@surmon-china/libundler'
export default defineConfig({
entry: 'src/index.js',
// ...
})
const libundler = require('@surmon-china/libundler')
libundler
.bundle({
/* LibundlerConfig */
})
.then((result) => {
console.log('bundle success', result)
})
.catch((error) => {
console.log('bundle error', error)
})
yarn dev
yarn lint
yarn build
yarn release
Detailed changes for each release are documented in the release notes.