TypeScript Version: 3.5
Webpck Version: 3.x
ts-loader Version: 3.x
Browser: IE8
Code
function load(type: string): Promise<any> {
return import(
`./types/${type}`
)
}
Expected behavior:
output compatible code
Actual behavior:
webpackJsonp(["chunk-file"],[
/* 0 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony default export */ __webpack_exports__["default"] = ({
type: 'basic'
});
/***/ })
]);
Related Issues:
https://github.com/microsoft/TypeScript/issues/14495
when the target is es3,module import call transform should output compatible defineProperty
Why do you think it is a TypeScript issue? It looks like it is something webpack is injecting.
Why do you think it is a TypeScript issue? It looks like it is something webpack is injecting.
see https://github.com/microsoft/TypeScript/issues/14495 and https://github.com/microsoft/TypeScript/blob/master/src/compiler/transformers/module/module.ts#L620
I think this is a webpack problem. Typescript don't generate outputs with webpackJsonp, __webpack_exports__ or __webpack_require__ references.
I cannot reproduce using only typescript:
tsconfig.json:
{
"compilerOptions": {
"module": "esnext",
"target": "es3",
"lib": ["es2015"]
},
"include": [
"./**/*.ts"
]
}
file (the same as yours):
function load(type: string): Promise<any> {
return import(
`./types/${type}`
)
}
typescript 3.5.3, 3.6.3 and 3.7.0-dev.20190919 outs the same:
function load(type) {
return import("./types/" + type);
}
Most helpful comment
I think this is a webpack problem. Typescript don't generate outputs with
webpackJsonp,__webpack_exports__or__webpack_require__references.I cannot reproduce using only typescript:
tsconfig.json:
file (the same as yours):
typescript 3.5.3, 3.6.3 and 3.7.0-dev.20190919 outs the same: