-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
CommittedThe team has roadmapped this issueThe team has roadmapped this issueFixedA PR has been merged for this issueA PR has been merged for this issueSuggestionAn idea for TypeScriptAn idea for TypeScript
Milestone
Description
CommonJS cannot requires a package transpiled from TypeScript ES6 Modules using default export well.
TS 1.5-alpha transpiles default exports:
// foo.ts
export default foo;to:
// foo.js ("main" in this package.json)
exports.default = foo;So users of this package foo need to add .default property to require().
var foo = require('foo').default;It's a little messy...
Babel resolves this issue.
http://babeljs.io/docs/usage/modules/#interop
Interop
In order to encourage the use of CommonJS and ES6 modules, when exporting a default
export with no other exportsmodule.exportswill be set in addition toexports["default"].export default test;exports["default"] = test; module.exports = exports["default"];If you don't want this behaviour then you can use the
commonStrictmodule formatter.
It sounds pretty nice and actually works for me.
sebilasse, zeh, arnaud, alex-kinokon, ralyodio and 29 moreljqx, ahocevar and lexon0011
Metadata
Metadata
Assignees
Labels
CommittedThe team has roadmapped this issueThe team has roadmapped this issueFixedA PR has been merged for this issueA PR has been merged for this issueSuggestionAn idea for TypeScriptAn idea for TypeScript