Packages Babel files into runnable Node.js code using [Webpack](https://webpack.js.org/).
Last updated a year ago by playfulcorgi .
MIT · Original npm · Tarball · package.json
$ cnpm install @playfulcorgi/node-transpile 
SYNC missed versions from official npm registry.


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.


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

npm install --save-dev node-transpile


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.2.1                                ...           latest (a year ago)

3 Versions

  • 1.2.1                                ...           a year ago
  • 1.2.0                                ...           a year ago
  • 1.1.3                                ...           a year ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 1
Last Month 2
Dev Dependencies (0)
Dependents (0)

Copyright 2014 - 2017 © taobao.org |