Giter VIP home page Giter VIP logo

babel-plugin-add-import-extension's Introduction

babel-plugin-add-import-extension

A plugin to add extensions to import declarations, is very useful when you use Typescript with Babel and don't want to explicity import .js modules.

How to install:

# using npm
npm install --save-dev babel-plugin-add-import-extension
# usin yarn
yarn add -D babel-plugin-add-import-extension

Add to your plugins on your babel config file:

plugins: ['babel-plugin-add-import-extension'] // defaults to .js extension

Is possible to set the extension when you set the plugin:

plugins: [
    ['babel-plugin-add-import-extension', 'jsx'] // will add jsx extension
  ]

Let's the transformation begin :)

A module import without extension:

import { add, double } from './lib/numbers'

will be converted to:

import { add, double } from './lib/numbers.js'

Remember that this plugin will not override extensions.

What this plugin does is to check all imported modules and if your module is not on node_module it will consider that is a project/local module and add the choosed extension, so for node modules it don't add any extension.

I made this plugin for personal use on my typescript boilerplate, but if a lot of people start to use I can add tests and some documentation ;)

babel-plugin-add-import-extension's People

Contributors

banou26 avatar karlprieb avatar

Watchers

 avatar  avatar

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.