node-transpile

Packages Babel files into runnable Node.js code.

Package renamed to @playfulcorgi/node-transpile
Last updated a year ago by playfulcorgi .
MIT · Original npm · Tarball · package.json
$ cnpm install node-transpile 
SYNC missed versions from official npm registry.

node-transpile

Packages Babel files into runnable Node.js code using Webpack.

The goal is to have an incredibly simple way of generating Node.js projects using the newest and sometimes experimental JavaScript syntax. Also, using Webpack and Babel for Node.js packages is a little different than for front-end packages. For example, there's no need to support older browsers. node-transpile already contains an appropriate configuration for this task.

Quickstart

First, add node-transpile as a dev dependency to a Node.js project:

npm install --save-dev node-transpile

or

yarn add --dev node-transpile

Second, inside package.json, add scripts:

"scripts": {
  "build": "node-transpile build",
  "watch": "node-transpile watch"
}

Third, inside package.json set main:

"main": "dist/index.js"

With the above configuration, node-transpile will process src/index.js into dist/index.js.

Custom Webpack Configuration

Create node-transpile.js, which will export a function. This function will be called by node-transpile to receive a complete Webpack configuration object. As the first parameter, it will receive whatever base configuration node-transpile created for itself.

For example, to add Webpack aliases for easier module resolution:

const { resolve } = require('path')
const set = require('lodash/set')
const baseDirectoryPath = __dirname
const srcDirectoryPath = resolve(baseDirectoryPath, 'src')

module.exports = (options) => {
  set(options, 'resolve.alias.fu', resolve(srcDirectoryPath, 'functional-utils/'))
  set(options, 'resolve.alias.utils$', resolve(srcDirectoryPath, 'functional-utils/utils.js'))
}

Current Tags

  • 1.1.1                                ...           latest (a year ago)

3 Versions

  • 1.1.1 [deprecated]           ...           a year ago
  • 1.1.0 [deprecated]           ...           a year ago
  • 1.0.0 [deprecated]           ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 4
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |