babel-plugin-remove-import-export
A babel plugin to remove import and export declaration in the source file.
This will be useful if you just want to provide a code snippet without the extra module syntex, for example LeetCode.
Warning: This plugin will break the context of the script, use with caution.
Example
In
; { return 'bar';} { return a + b; } ;
Out
{ return 'bar';} { return a + b; }
Installation
yarn add -D babel-plugin-remove-import-export
Or, use npm:
npm install babel-plugin-remove-import-export --save-dev
Usage
.babelrc
(Recommended)
Via .babelrc
// without options // with options
Via CLI
babel --plugins remove-import-export script.js
Via Node API
;
Options
removeImport
boolean
, defaults to true
.
removeExport
boolean
, defaults to true
.
removeExportDefault
boolean
, defaults to true
. Set this option to false
will preserve the default export.
preseveNamedDeclaration
boolean
, defaults to true
.
Set In OutExample
preseveNamedDeclaration
to false
will not keep the declaration after export
keyword.