A Babel plugin that strips import and export declarations from source files, useful for preparing code snippets for platforms like LeetCode. Current stable version is 1.1.1 (last updated 2020). It is lightweight and simple, with no dependencies. Options allow selective removal of imports, exports, or default exports, and control over preserving named export declarations. Unlike general code cleanup tools, it specifically targets module syntax only.
npm install babel-plugin-remove-import-exportVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic usage: removing import/export declarations from a source file, preserving only the body.
Use option name exactly as spelled: 'preseveNamedDeclaration' (not 'preserveNamedDeclaration').
Manually ensure removed imports are not used in the remaining code, or use a bundler/linter to detect dangling references.
Set 'removeExportDefault' to false in options to preserve default export.
Avoid using with re-export statements, or test output manually.
Run: npm install --save-dev babel-plugin-remove-import-export. Ensure .babelrc uses 'remove-import-export' (not the full name).
In .babelrc, use: "plugins": [["remove-import-export", { "removeImport": false }]]Verify option spelling; e.g., 'preseveNamedDeclaration' not 'preserveNamedDeclaration'. Also check .babelrc correct syntax.
No dependency data recorded yet.