You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Starting from typescript 2.2, when files are compiled it is added a new statement like Object.defineProperty(exports, "__esModule", { value: true });.
So a tsconfig file with
which results in runtime error because of the usage of exports outside the define wrapper.
Why the compiled code is not wrapped in a define function?
If a file doesn't have any import statement is not wrapped in a define function, in that case add an empty export.
See microsoft/TypeScript#20943
Import module object
Add this line to be able to use module directly. It is a deprecated syntax but I didn't find anything better. /// <amd-dependency path="module" name="module"/>
Compatibility TypeScript and RequireJS
Use export = Foo when RequireJS uses module.exports = Foo.
Some tips to compile to AMD.
Configuration
A minimal
tsconfig.json
should be:Why commonjs doesn't work
Starting from typescript 2.2, when files are compiled it is added a new statement like
Object.defineProperty(exports, "__esModule", { value: true });
.So a tsconfig file with
will result in
which results in runtime error because of the usage of
exports
outside thedefine
wrapper.Why the compiled code is not wrapped in a
define
function?If a file doesn't have any
import
statement is not wrapped in adefine
function, in that case add an emptyexport
.See microsoft/TypeScript#20943
Import
module
objectAdd this line to be able to use
module
directly. It is a deprecated syntax but I didn't find anything better./// <amd-dependency path="module" name="module"/>
Compatibility TypeScript and RequireJS
Use
export = Foo
when RequireJS usesmodule.exports = Foo
.Track of changes
After the merge with Brackets commits:
The text was updated successfully, but these errors were encountered: