Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-middleware

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-middleware - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

22

index.js

@@ -1,4 +0,6 @@

var babel = require('babel-core');
var fs = require('fs');
var path = require('path');
var crypto = require('crypto');
var babel = require('babel-core');
var micromatch = require('micromatch');

@@ -25,2 +27,3 @@

var exclude = options.exclude || [];
var debug = options.debug || false;

@@ -41,8 +44,14 @@ // filename to last known hash map

function log() {
if (debug) {
console.log.apply(undefined, arguments);
}
}
function pathForHash(hash) {
return cachePath + '/' + hash + '.js';
return path.resolve(cachePath + '/' + hash + '.js');
}
return function(req, res, next) {
var src = srcPath + '/' + req.path; // XXX Need the correct path
var src = path.resolve(srcPath + '/' + req.path); // XXX Need the correct path
var hash = fileLastModifiedHash(src);

@@ -54,3 +63,3 @@ var lastKnownHash = hashMap[src];

if (micromatch.any(req.path.replace(/^\/+|\/+$/g, ''), exclude)) {
console.log('Excluded: %s (%s)', req.path, exclude);
log('Excluded: %s (%s)', req.path, exclude);
res.append('X-Babel-Cache', false);

@@ -66,2 +75,4 @@ res.sendFile(src, {}, function(err) {

log('Preparing: %s (%s)', src, hash);
res.append('X-Babel-Cache', true);

@@ -101,5 +112,7 @@ res.append('X-Babel-Cache-Hash', hash);

if (isMemoryCache) {
log('Serving (cached): %s', src);
res.write(cacheMap[hash]);
res.end();
} else {
log('Serving (cached): %s', hashPath);
res.sendFile(hashPath, {}, function(err) {

@@ -145,2 +158,3 @@ if (err) {

}
log('Serving (uncached): %s', src);
res.write(code);

@@ -147,0 +161,0 @@ res.end();

2

package.json
{
"name": "babel-middleware",
"version": "0.2.0",
"version": "0.2.1",
"description": "Express/Connect middleware to pre-process requested JS files through Babel",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -45,2 +45,7 @@ babel-middleware

### `debug: true|false`
Print debug output.
Default: _false_
LICENSE

@@ -47,0 +52,0 @@ =======

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc