treeshaking
v1.0.8
Published
tree shake es_module in memory
Downloads
7
Readme
tree-shaking
tree shake es_module in memory
Install
npm install treeshaking -save-dev
Demo
import treeShaking from 'treeshaking'
treeShaking({
'index.js': `
import foo from 'foo'
import bar from './src/bar'
const baz = 3 // baz will not be output
console.log(foo, bar)
`,
'foo/index.js': `
export default 1
export function hello () { // hello will not be output
alert(hello)
}
`,
'src/bar.js': `
export default 2
`
}, {
entry: 'index.js' // default
}).then(({code}) => {
console.log(code)
})
output:
'use strict';
var foo = 1
var bar = 2
console.log(foo, bar);
API
treeShaking(modules, options?: Options)
Options
interface Options {
entry?: string,
format?: 'amd' | 'cjs' | 'es' | 'es6' | 'iife' | 'umd',
name?: string
}