Closed zerkms closed 6 years ago
Ok, after more research it looks like it has nothing to do with the awesome-typescript-loader
but it's typescript that emits such code: https://www.typescriptlang.org/play/#src=const%20p%20%3D%20new%20Promise(()%20%3D%3E%20%7B%7D)%3B%0D%0A%0D%0Aexport%20default%20p%3B%0D%0A
const p = new Promise(() => {});
export default p;
->
define(["require", "exports"], function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var p = new Promise(function () { });
exports.default = p;
});
Please close this issue if that's the case.
A repository with reproduction: https://github.com/zerkms/awesome-typescript-loader-usebuiltins
Explanation:
This is what emitted when I use
@babel/preset-env
option"useBuiltIns": "usage"
and try to use runtime objects from newer JS standards (most of the output is omitted for readability):source file:
generated output
As you may see
awesome-typescript-loader
expects the exporting object to be namedexports
, while babel (or itspreset-env
plugin) has changed it to__webpack_exports__
As expected - this code would fail with undefined reference
exports
.While that's what is emitted if used just js
After thinking for a moment, I'm not sure anymore if it's the
awesome-typescript-loader
ortypescript
's issue.