hops-transpiler

Hops wrapper for Webpack

This package is deprecated. Please use hops-middleware instead.
Last updated 2 years ago by dmbch .
MIT · Original npm · Tarball · package.json
$ cnpm install hops-transpiler 
SYNC missed versions from official npm registry.

Hops Transpiler

deprecated

This package is deprecated. Please use hops-middleware instead.

npm

Hops transpiler is a very simple wrapper around Webpack's compiler and it is its most bare-bones, lowest-level component. It exports a function creating an event emitter that is set up to emit three kinds of events: start, success and error.

The start event is emitted whenever a transpilation run is started. If the transpiler is created with watchOptions, the start event will be emitted whenever a recompilation occurs.

The success event is emitted whenever a compilation finishes successfully. It comes with the transpilation result (as a plain node module) and the Webpack stats object.

The error event is emitted whenever anything goes haywire during transpilation and import. The transpiler takes care of Webpack's idiosyncrasies with regards to error handling and is extremely strict - even warnings are emitted as errors.

You can override hops' default Webpack configuration by passing a webpackConfig object to the transpile function. You can also enable watch mode by passing a watchOptions object.

Target Audience

If you want to use dynamically transpiled ECMAScript Next code (i.e. no Express middleware) in your Node.js code, you'll probably want to use it. Just make sure you export something from your module - whatever it is, the transpiler will emit it with its success event.

Example

This example shows how to create a generic ECMAScript Next module and use it in your code.

package.json
{
  ...
  "server": "src/server.js",
  "main": "index.js",
  "dependencies": {
    "hops-build-config": "*",
    "hops-transpiler": "*"
  }
  ...
}
src/server.js
export default `hello foo`;
index.js
const transpile = require('hops-transpiler');
const webpackConfig = require('hops-build-config').nodeConfig;
const transpilation = transpile(webpackConfig /*, watchOptions */);

transpilation.on('success', function(result) {
  // result === 'hello foo'
});

Hops' own middleware probably is the best example of the transpiler in action.

Current Tags

  • 9.4.1                                ...           latest (2 years ago)
  • 7.0.0-0                                ...           prerelease (3 years ago)

44 Versions

  • 9.4.1 [deprecated]           ...           2 years ago
  • 9.1.1                                ...           2 years ago
  • 9.0.1                                ...           2 years ago
  • 7.2.0                                ...           3 years ago
  • 7.1.0                                ...           3 years ago
  • 7.0.0                                ...           3 years ago
  • 7.0.0-0                                ...           3 years ago
  • 6.2.8                                ...           3 years ago
  • 6.2.7                                ...           3 years ago
  • 6.2.6                                ...           3 years ago
  • 6.2.5                                ...           3 years ago
  • 6.2.4                                ...           3 years ago
  • 6.2.3                                ...           3 years ago
  • 6.2.2                                ...           3 years ago
  • 6.2.0                                ...           3 years ago
  • 6.1.2                                ...           3 years ago
  • 6.1.1                                ...           3 years ago
  • 6.1.0                                ...           3 years ago
  • 6.0.0                                ...           3 years ago
  • 6.0.0-beta.24                                ...           3 years ago
  • 6.0.0-beta.23                                ...           3 years ago
  • 6.0.0-beta.22                                ...           3 years ago
  • 6.0.0-beta.21                                ...           3 years ago
  • 6.0.0-beta.g20                                ...           3 years ago
  • 6.0.0-beta.19                                ...           3 years ago
  • 6.0.0-beta.18                                ...           3 years ago
  • 6.0.0-beta.17                                ...           3 years ago
  • 6.0.0-beta.16                                ...           3 years ago
  • 6.0.0-beta.15                                ...           3 years ago
  • 6.0.0-beta.14                                ...           3 years ago
  • 6.0.0-beta.13                                ...           3 years ago
  • 6.0.0-beta.12                                ...           3 years ago
  • 6.0.0-beta.11                                ...           3 years ago
  • 6.0.0-beta.10                                ...           3 years ago
  • 6.0.0-beta.9                                ...           3 years ago
  • 6.0.0-beta.8                                ...           3 years ago
  • 6.0.0-beta.7                                ...           3 years ago
  • 6.0.0-beta.6                                ...           3 years ago
  • 6.0.0-beta.5                                ...           3 years ago
  • 6.0.0-beta.4                                ...           3 years ago
  • 6.0.0-beta.3                                ...           3 years ago
  • 6.0.0-beta.2                                ...           3 years ago
  • 6.0.0-beta.1                                ...           3 years ago
  • 0.1.0                                ...           3 years ago
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 0
Last Month 45
Dependencies (4)
Dev Dependencies (0)
None
Dependents (1)

Copyright 2014 - 2017 © taobao.org |