This package has been deprecated

Author message:

Development of this module has been stopped.

babel-node-modules

0.0.1 • Public • Published

babel node_modules

NPM version Build status License Code style

simple wrapper for babel-register to make including ES6 modules easier

Installation

$ npm install --save-dev babel-node-modules

...or:

$ yarn add --dev babel-node-modules

Motivation

This is for making the process of using ES6/ES2015 modules (using import syntax rather than CommonJS's require style) in projects easier, especially when testing, which can be a bit of a nightmare. This is specifically for when an ES6 module has been installed via npm or yarn and resides somewhere in your node_modules/ directory.

Usage

First write your test file in ES6/ES2015, including importing any ES6/ES2016 modules.

test/test.js

import assert from 'assert'
import {hello} from 'helloworld'
 
describe('if this works, everything compiled fine', () => {
  it('string should match', () => {
    assert(hello() === 'hello stranger!')
    assert(hello('John') === 'hello John!')
  })
})

test/node_modules/helloworld/world.js

export function hello (name = 'stranger') {
  return `hello ${name}!`
}

test/node_modules/helloworld/package.json

{
  "name": "helloworld",
  "main": "world.js"
}

test/testPolyfill.js

require('babel-node-modules')([
  'helloworld' // add an array of module names here
])

...then run your tests:

$ mocha --require test/testPolyfill.js

Readme

Keywords

Package Sidebar

Install

npm i babel-node-modules

Weekly Downloads

53

Version

0.0.1

License

MIT

Last publish

Collaborators

  • roryrjb