felixge / node-sandboxed-module

A sandboxed node.js module loader that lets you inject dependencies into your modules.
MIT License
342 stars 42 forks source link

Litcoffee support #51

Closed svi3c closed 9 years ago

svi3c commented 9 years ago

Hello,

I just encountered a problem trying to test litcoffee modules.

The problem is a combination of three issues:

  1. The coffee build transformer is registered by default in lib/sandboxed_module.js:10 and you cannot deregister it:

    var registeredBuiltInSourceTransformers = ['coffee'];
  2. In lib/sandboxed_module.js:310 the expression

    this.filename.search('.coffee$')

    also matches .litcoffee files.

  3. built-in transformers are run before any custom build transformer

So I see three possible ways to get around the problem:

  1. Do not set the coffee transformer as default
  2. Use String.prototype.indexOf() instead of String.prototype.search() or escape the . at the beginning of the expression
  3. Provide the possibility to run custom transformers before the built-in transformers
domenic commented 9 years ago

Of those you mention, 2 sounds good no matter what. We should probably also do a 3.0.0 release that stops enabling coffee by default.