Registry / babel-plugin-transform-relative-paths

babel-plugin-transform-relative-paths

JSON →
library0.1.0jsnpmunverified

A Babel plugin that transforms relative import/require paths by adding an extra directory level (e.g., './' becomes '../', '../' becomes '../../'). Current stable version: 0.1.0. Release cadence is unknown. Differentiator: simple, no-config path manipulation for monorepos or code generators, but limited to single-level up transformation without custom configuration.

npm install babel-plugin-transform-relative-paths
INSTALL
IMPORT
SIG · BABEL-PLUGIN-TRANS
B
babel-plugin-transform-relative-paths
javascriptv0.1.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
module.exports = require('babel-plugin-transform-relative-paths');
import plugin from 'babel-plugin-transform-relative-paths';
This plugin is a CJS module; ESM import may work in some environments but is not guaranteed.
plugin usage
plugins: [require('babel-plugin-transform-relative-paths')]
plugins: ['babel-plugin-transform-relative-paths']
String shorthand works only if the plugin is installed and Babel resolves it; explicit require is safer.

Demonstrates Babel plugin configuration and transformation of relative paths by adding one directory level.

// .babelrc { "plugins": ["transform-relative-paths"] } // input.js import someModule from './a-relative-path'; import someOtherModule from '../a-relative-path'; const someCommonModule = require('../../a-relative-path'); // output.js (after transformation) import someModule from '../a-relative-path'; import someOtherModule from '../../a-relative-path'; const someCommonModule = require('../../../a-relative-path');
Debug
Known issues
gotchaPlugin transforms all relative paths in import/require statements indiscriminately, including those from node_modules if not excluded.
fix
Configure Babel to exclude node_modules via babel.config.js: module.exports = { plugins: [['transform-relative-paths']], only: ['./src'] };
affects: >=0.1.0
gotchaOnly supports moving paths up one level; cannot customize depth or transform in reverse.
fix
For custom transformations, consider using a different plugin or writing a custom one.
affects: >=0.1.0
gotchaPlugin does not handle dynamic requires or string concatenation in require() calls.
fix
Ensure your require() calls use static string literals.
affects: >=0.1.0
Errors
Common errors & fixes
Error: Cannot find module 'babel-plugin-transform-relative-paths'
Plugin not installed or Babel cannot resolve it.
fix
npm install --save-dev babel-plugin-transform-relative-paths
TypeError: (0 , _plugin.default) is not a function
Using ES module import syntax with a CJS plugin that does not export a default function.
fix
Use require('babel-plugin-transform-relative-paths') instead of import statement.
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Resources
babel-plugin-transform-relative-paths — npm install babel-plugin-transform-relative-paths · libregistry