是否可以使用TypeScript和Webpack来定位ES5,但是编写ES6风格的模块?
我想写这样的模块:
export class MyClass {
}
并像这样导入它们:
import {MyClass} from "Path/To/MyClass";
这适用于SystemJS和这样的tsconfig:
"compilerOptions": {
"target": "es5",
"module": "system",
}
但我想使用Webpack而不是SystemJS .
使用“system”作为模块设置,我可以理解为“系统未定义”为控制台错误 .
我是webpack的新手,但也许我可以使用ts-loader和babel-loader的组合?我只是找不到合适的配置 .
1 回答
是的你可以 . 在Webpack的第1版(当前版本)中,不支持系统 . 你必须将模块定位到这样的commonjs:
webpack的第2版将支持系统模块 .