Skip to content

Transform module using babel-explode-module to have a simpler structure

License

Notifications You must be signed in to change notification settings

babel-utils/babel-helper-simplify-module

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

babel-helper-simplify-module

Transform module using babel-explode-module to have a simpler structure

import {simplifyModule} from 'babel-helper-simplify-module';

simplifyModule(programPath);

Before:

import foo from "mod";
import {bar} from "mod";

export default function() {
  // ...
}

export const baz = 42,
             bat = "hello world";

export * from "bam";

After:

import foo, {bar} from "mod";

function _default() {
  // ...
}

const baz = 42;
const bat = "hello world";

export default _default;
export { baz };
export { bat };
export * from "bam";

API

explodedToStatements(exploded)

import explodeModule from 'babel-explode-module';
import {explodedToStatements} from 'babel-helper-simplify-module';

let exploded = explodeModule(node);
let statements = explodedToStatements(exploded);

simplifyModule(path)

This mutates the program.

import {simplifyModule} from 'babel-helper-simplify-module';

simplifyModule(programPath);

About

Transform module using babel-explode-module to have a simpler structure

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published