JSPM

babel-plugin-remove-import-export

1.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2588
  • Score
    100M100P100Q125288F
  • License MIT

A babel plugin to remove import and export declaration in the source file.

Package Exports

  • babel-plugin-remove-import-export

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (babel-plugin-remove-import-export) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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

import { LinkedList } from 'some-lib'

function foo(a, b) {
  return new LinkedList(['bar']);
}

export class Solution {
  add(a, b) {
    return a + b;
  }
}

export default foo;

Out

function foo(a, b) {
  return new LinkedList(['bar']);
}

class Solution {
  add(a, b) {
    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

{
  "plugins": ["remove-import-export"]
}

Via CLI

babel --plugins remove-import-export script.js

Via Node API

require("@babel/core").transform("code", {
  plugins: ["remove-import-export"]
});