0.1.1 • Published 6 years ago
babel-plugin-relativify-imports v0.1.1
babel-plugin-relativify-imports
Babel plugin to convert absolute import paths to relative paths.
Example, given this code in /src/folder/module.js
:
import { OtherModule } from '/src/other-folder/other-module.js'
import '/src/folder/subfolder/submodule1.js'
async function getSubmodule2Lazily() {
const { submodule2 } = await import('/src/folder/subfolder/submodule2.js')
submodule2.method()
}
export * from '/src/folder/subfolder/submodule3.js'
Will become:
import { OtherModule } from '../other-folder/other-module.js'
import './subfolder/submodule1.js'
async function getSubmodule2Lazily() {
const { submodule2 } = await import('./subfolder/submodule2.js')
submodule2.method()
}
export * from './subfolder/submodule3.js'
Note: to convert bare module imports (import { Module } from '@organization/module'
), please use cfware/babel-plugin-bare-import-rewrite before this plugin in your babel plugin chain.
Usage
Add to your project:
npm install babel-plugin-relativify-imports
Add relativify-imports
to plugins
in your babel settings:
{
"plugins": ["relativify-imports"]
}
Contributing
Install
npm install
Test
npm test