TypeScript is adding Object.defineProperty(exports, "__esModule", { value: true }); throwing an error
Asked Answered
P

1

7

I have recently updated typescript at the new version 2.2.1 after this I began to receive this error on the browser:

Uncaught (in promise) Error: "exports is not defined"

I noticed that typescript is adding this line after "use strict" at the began of the .js transpile file when the there is an import statement at the .ts file.

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

So I re installed the previous version 2.1.6 and that line disappeared and everything works fine again.

Is this an expected behavior of this new version? How could I go throw this?

By the way I'm using SystemJS with JSPM

Paries answered 16/3, 2017 at 14:10 Comment(2)
Thanks for this question! I did the same to avoid this exports is not defined problem! Eagerly waiting for the answer. :)Pelting
@AshokMA I'm wondering why the angular 2 developers are not reporting this same issue... It's been a while. weird!Paries
R
5

I find the same issue. Uncaught ReferenceError: exports is not defined and require

This solution is work for me. I change the setting of "tsconfig.json"

{
  "compilerOptions": {
    "target": "es5",
    "module": "umd"
  }
}
Rhapsodic answered 12/4, 2017 at 3:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.