Web Compiler converting CoffeeScript to JavaScript with require()

311 views Asked by At

I'm using Web Compiler for Visual Studio 2015, and I'm trying to compile a coffeescript file into a normal javascript file, but whenever I compile the coffeescript.js file I get the javascript.js, but with:

// Generated by IcedCoffeeScript 108.0.11
(function() {
var iced;

iced = require('iced-runtime');
...

appended to the beginning. We don't use Node.js, so the require() fails and hence my AngularJS controller is unrecognized.

Is there a setting within Web Compiler that disables the insertion of the above? I just want the coffeescript compiled into normal JS.

1

There are 1 answers

1
vijoc On BEST ANSWER

The Web Compiler seems to be using the IcedCoffeeScript compiler, with the --runtime flag defaulting to node, causing the require you see.

You should have a compilerconfig.json at the project root. Try setting an explicit option for the runtime:

compilers: {
  coffeescript: {
    runtimeMode: 'inline' // or 'window' or even 'none'
  }
}