New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

babel-node-modules

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-node-modules

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

latest
Source
npmnpm
Version
0.0.1
Version published
Maintainers
1
Created
Source

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

Keywords

babel

FAQs

Package last updated on 18 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts