treeshaking
tree shake es_module in memory
Last updated a year ago by char1ee .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install treeshaking 
SYNC missed versions from official npm registry.

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
}

Current Tags

  • 1.0.8                                ...           latest (a year ago)

9 Versions

  • 1.0.8                                ...           a year ago
  • 1.0.7                                ...           a year ago
  • 1.0.6                                ...           a year ago
  • 1.0.5                                ...           a year ago
  • 1.0.4                                ...           a year ago
  • 1.0.3                                ...           a year ago
  • 1.0.2                                ...           a year ago
  • 1.0.1                                ...           a year ago
  • 1.0.0                                ...           a year ago
Maintainers (1)
Downloads
Today 1
This Week 1
This Month 7
Last Day 0
Last Week 5
Last Month 17
Dependencies (1)
Dev Dependencies (6)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |