Title basically says it all.
Here is my config:
{
"compilerOptions": {
"sourceMap": true,
"watch": true,
"outDir": "Source_JS",
"forceConsistentCasingInFileNames": true,
// this is the important line
"module": "es2015",
"moduleResolution": "node",
"rootDir": "Source",
"baseUrl": "Source",
"paths": {
"*": [
"../node_modules/@types/*",
"*"
]
},
"target": "esnext",
"lib": [
"es6",
"es5",
"dom"
],
"allowJs": true,
"jsx": "react",
"noImplicitAny": false,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true
},
"files": ["Source/Main.ts"],
"include": [
"Typings/**/*.d.ts",
"Source/**/*.ts",
"Source/**/*.tsx"
],
"exclude": [
"Build",
"Tests",
"node_modules"
],
"compileOnSave": true
}
I had to add the module: "es2015" line, because the handling was different between tsc and ts-loader, and it was causing problems in my project.
It was confusing because I expected an identical config file to give the same results in both tsc and ts-loader.
For reference, the difference in output between ts-loader and tsc when the "module" config was not specified, is that tsc would (correctly) output:
var _ajv = __webpack_require__(614);
var _ajv2 = _interopRequireDefault(_ajv);
var instance = new _ajv2.default();
Whereas ts-loader would output:
var _ajv = __webpack_require__(651);
var instance = new _ajv.default();
The first output is correct since "babel-plugin-transform-es2015-modules-commonjs" with default settings is enabled in the project.
I believe this can be fixed by just having the default value for "module" match that of tsc (by being "es2015"), for when it's not specified in tsconfig.json (as was the case in my project).
Title basically says it all.
Here is my config:
I had to add the
module: "es2015"line, because the handling was different between tsc and ts-loader, and it was causing problems in my project.It was confusing because I expected an identical config file to give the same results in both tsc and ts-loader.
For reference, the difference in output between ts-loader and tsc when the "module" config was not specified, is that tsc would (correctly) output:
Whereas ts-loader would output:
The first output is correct since "babel-plugin-transform-es2015-modules-commonjs" with default settings is enabled in the project.
I believe this can be fixed by just having the default value for "module" match that of tsc (by being "es2015"), for when it's not specified in tsconfig.json (as was the case in my project).