Code Monkey home page Code Monkey logo

babel-plugin-orbit-components's Introduction

babel-plugin-orbit-components

Build Status

Transforms destructured imports of @kiwicom/orbit-components to granular ones!


Note: This project was moved to the monorepo.


Setup

Install:

  • yarn add -D @kiwicom/babel-plugin-orbit-components

Then just add @kiwicom/orbit-components to the list of babel plugins, e.g. to .babelrc:

{
  "plugins": ["@kiwicom/orbit-components"]
}

Examples

// Input:
import { Alert } from '@kiwicom/orbit-components';

// Output:
import Alert from '@kiwicom/orbit-components/lib/Alert';
// Input
import { Passengers } from '@kiwicom/orbit-components/lib/icons';

// Output
import Passengers from '@kiwicom/orbit-components/lib/icons/Passengers';

License

MIT

babel-plugin-orbit-components's People

Contributors

jaroslav-kubicek avatar mrtnzlml avatar oreqizer avatar silvenon avatar tbergquist-godaddy avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

bvego

babel-plugin-orbit-components's Issues

A solution for ESM

It would be great if this plugin did the right thing when being used by ESM-capable tools like webpack, to allow tree-shaking, like switch to the es directory instead of lib. Maybe this could be a modules option, like in @babel/preset-env, which defaults to auto. Babel is able to detect whether the tool it's being used by supports ESM:

module.exports = api => {
  api.caller(caller => {
    caller.supportsStaticESM
  })
  return {
    // ..
  }
}

But it should still be configurable. Consult @babel/preset-env's index.js file for inspiration.

Importing all Icons breaks pathing

Importing:

import { Icons } from '@kiwicom/orbit-components'

will get translated to:

import { Icons } from '@kiwicom/orbit-components/lib/Icons'

However the path on filesystem is:

@kiwicom/orbit-components/lib/icons

Path of Grid is not correctly resolved

Using:

import { Text, Stack, Grid } from '@kiwicom/orbit-components';

gets translated to:

@kiwicom/orbit-components/lib/Grid

However the correct path is:

import Grid from '@kiwicom/orbit-components/lib/utils/Grid';

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.