Git Product home page Git Product logo

babel-plugin-project-relative-require's Introduction

Note this is a Babel 5 plugin.

I'm now personally use - https://github.com/jshanson7/babel-plugin-resolver plugin that supports babel 6

babel-plugin-project-relative-require

npm version

A Bable plugin for importing modules relative to the current working directory (cwd). Idea taken from FakeRainBrigand answer http://stackoverflow.com/a/31069137/1329668

Example

In

import myModule from 'cwd://mymyModule';

Out

import myModule from '<relative_path_from_your_current_place>mymyModule';

Installation

$ npm install babel-plugin-project-relative-require

Usage

Via .babelrc (Recommended)

.babelrc

{
  "plugins": ["babel-plugin-project-relative-require"]
}

Via CLI

$ babel --plugins babel-plugin-project-relative-require script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["babel-plugin-project-relative-require"]
});

babel-plugin-project-relative-require's People

Contributors

gavriguy avatar yormi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

ben-x9

babel-plugin-project-relative-require's Issues

TypeError: babel.Transformer is not a function

@gavriguy First of all thanks for going the extra mile and making this solution available as a plugin.

I am getting something like :

...
/node_modules/babel-plugin-project-relative-require/index.js:8
  return new babel.Transformer("babel-plugin-project-relative-require", {
         ^

TypeError: babel.Transformer is not a function
...

after installing this, adding to .babelrc and my webpack.config.js (maybe redundant to do both) and trying to use with the cwd:// import sytax.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.