imod
Version:
A bundler for tiny modules, powered by Rollup.
94 lines (74 loc) • 1.8 kB
Markdown
---
```bash
yarn global add imod
sudo npm install imod -g
```
```bash
imod init ./hello
```
add these into [package.json](https://github.com/haozi/imod-template-module/blob/master/package.json#L7)
```json
{
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/types/index.d.ts",
"scripts": {
"build": "imod build",
"dev": "imod dev"
}
}
```
```bash
imod dev
imod build
```
```typescript
import Imod from 'imod'
const iMod = new IMod({
cwd: __dirname + '/../..'
})
iMod.build()
iMod.dev()
```
```bash
imod init ./hello --templateName=module --lite=true
```
* you can add a config at `package.json`, `./imod.config.js`, `./imod.config.json`, `./imodconfig.js`, `./imodconfig.json`
* The order in which imod looks up is `./imod.config.js` -> `./imod.config.json` -> `imodconfig.js` -> `imodconfig.json` -> `${package.json}.config.imod`
this is the default configuration:
```javascript
module.exports = {
name: moduleName, // if not set, will guess from ${package.json}.name
banner: '', // if not set, return ''
input: '', // string | string[] | null. if not set, will find src/index*{.ts,.tsx,.js,.jsx,.es6,.es,.mjs}
outDir: '', // string. default is './dist'
declarationDir: false, // string | false. if false will no typings
compilerOptions: [
{
format: 'esm',
extName: '.mjs',
target: 'esnext'
},
{
format: 'cjs',
extName: '.js',
target: 'es5'
},
{
format: 'umd',
extName: '.min.js',
target: 'es5'
}
]
}
```