karma-typescript-preprocessor icon indicating copy to clipboard operation
karma-typescript-preprocessor copied to clipboard

Exports added when module = "none"

Open mike-ward opened this issue 8 years ago • 4 comments

This seems to be related to the recent introduction of VS 2017.

With the preprocessor options of:

typescriptPreprocessor: {
      target: 'ES5',
      module: 'none',
      sourceMap: false,
      noImplicitAny: false
    },

When I run Karma I get:

Uncaught ReferenceError: exports is not defined
  at apps/controls/app-controls.js:4

and the code in the generated JavaScript contains:

"use strict";
exports.__esModule = true;
angular.module('controls.directives', []);
angular.module('controls.filters', ['controls.services']);
angular.module('controls.services', []);
...

mike-ward avatar Mar 08 '17 19:03 mike-ward

I'm having the same issue. It happened when I tried to update to TypeScript 2.2.1 but it works in 2.1.6.

olivierbelzile avatar Mar 16 '17 15:03 olivierbelzile

this is an issue with typescript and ist discussed here https://github.com/Microsoft/TypeScript/issues/14351 and here https://github.com/Microsoft/TypeScript/issues/14456

it will be fixed in typescript 2.3 https://github.com/Microsoft/TypeScript/pull/14493

giniedp avatar Mar 26 '17 10:03 giniedp

it works when i install typescript@next as a dependency. However, you have to tell the preprocessor explicitely what typescript version should be used. Looks like this:

    typescriptPreprocessor: {
      options: require('./tsconfig').compilerOptions,
      typescript: require('typescript')
    },

giniedp avatar Mar 26 '17 11:03 giniedp

Any updates on this, I'm still getting: exports.__esModule = true; with those configs: { "compilerOptions": { "rootDir": "./src/", "alwaysStrict": false, "baseUrl": "./", "target": "ES3", "lib":["ES5", "ES2015.Promise"], "outDir":"./dist/", "module": "none" } }

I'm using 2.9.0-dev.20180403

faresd avatar Apr 03 '18 16:04 faresd