treeshaking
TypeScript icon, indicating that this package has built-in type declarations

1.0.8 • Public • Published

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
}

Readme

Keywords

none

Package Sidebar

Install

npm i treeshaking

Weekly Downloads

1

Version

1.0.8

License

MIT

Last publish

Collaborators

  • char1ee