Git Product home page Git Product logo

broccoli-cjs-to-es6's Introduction

broccoli-cjs-to-es6

This plugin transform your CommonJS deps making them usable like ES6 modules in Ember. Many thanks to the Ember Browserify addon for the idea.

⚠️ NOTE ⚠️: This project has been quick hacked so it's far from perfect. I assume no responsibilities.

Installation

npm install --save broccoli-cjs-to-es6

Example

Suppose you have 2 cjs packages in node_modules called very-long-package-name and simple-pkg. In a standard node env you would use them like this:

// node env
const veryLongPackageName = require("very-long-package-name");
const simplePkg = require("simple-pkg");

If you want to use them in ember just you can do something like this:

const browserifyTree = require("broccoli-cjs-to-es6");

module.exports = {
  name: "awesome-addon",

  treeForVendor(tree) {
    return browserifyTree(tree, {
      modules: [
        {
          module: "very-long-package-name",
          resolution: "short-name"
        },
        "simple-pkg"
      ],
      outputFile: "whatever-file-name.js"
    });
  },

  included(app) {
    app.import("vendor/whatever-file-name.js");
  }
};

Then in your Ember app you can access them like this:

import veryLongPackageName from "short-name";
import simplePkg from "simple-pkg";

broccoli-cjs-to-es6's People

Contributors

fed03 avatar

Watchers

 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.