diff options
Diffstat (limited to 'node_modules/ts-loader/dist')
-rw-r--r-- | node_modules/ts-loader/dist/index.js | 19 | ||||
-rw-r--r-- | node_modules/ts-loader/dist/instances.js | 7 |
2 files changed, 19 insertions, 7 deletions
diff --git a/node_modules/ts-loader/dist/index.js b/node_modules/ts-loader/dist/index.js index 335c1b190..7a1e59041 100644 --- a/node_modules/ts-loader/dist/index.js +++ b/node_modules/ts-loader/dist/index.js @@ -32,10 +32,13 @@ function loader(contents) { throw new Error("Typescript emitted no output for " + filePath + "." + additionalGuidance); } var _c = makeSourceMap(sourceMapText, outputText, filePath, contents, this), sourceMap = _c.sourceMap, output = _c.output; - // Make sure webpack is aware that even though the emitted JavaScript may be the same as - // a previously cached version the TypeScript may be different and therefore should be - // treated as new - this._module.meta.tsLoaderFileVersion = fileVersion; + // _module.meta is not available inside happypack + if (!options.happyPackMode) { + // Make sure webpack is aware that even though the emitted JavaScript may be the same as + // a previously cached version the TypeScript may be different and therefore should be + // treated as new + this._module.meta.tsLoaderFileVersion = fileVersion; + } callback(null, output, sourceMap); } /** @@ -65,10 +68,13 @@ function getLoaderOptions(loader) { compilerOptions: {}, appendTsSuffixTo: [], entryFileIsJs: false, + happyPackMode: false, }, configFileOptions, queryOptions); options.ignoreDiagnostics = utils.arrify(options.ignoreDiagnostics).map(Number); options.logLevel = options.logLevel.toUpperCase(); options.instance = instanceName; + // happypack can be used only together with transpileOnly mode + options.transpileOnly = options.happyPackMode ? true : options.transpileOnly; loaderOptionsCache[instanceName] = options; return options; } @@ -136,7 +142,10 @@ function getTranspilationEmit(filePath, contents, instance, loader) { reportDiagnostics: true, fileName: fileName, }), outputText = _a.outputText, sourceMapText = _a.sourceMapText, diagnostics = _a.diagnostics; - utils.registerWebpackErrors(loader._module.errors, utils.formatErrors(diagnostics, instance.loaderOptions, instance.compiler, { module: loader._module })); + // _module.errors is not available inside happypack - see https://github.com/TypeStrong/ts-loader/issues/336 + if (!instance.loaderOptions.happyPackMode) { + utils.registerWebpackErrors(loader._module.errors, utils.formatErrors(diagnostics, instance.loaderOptions, instance.compiler, { module: loader._module })); + } return { outputText: outputText, sourceMapText: sourceMapText }; } function makeSourceMap(sourceMapText, outputText, filePath, contents, loader) { diff --git a/node_modules/ts-loader/dist/instances.js b/node_modules/ts-loader/dist/instances.js index fc9c13cc5..10227547a 100644 --- a/node_modules/ts-loader/dist/instances.js +++ b/node_modules/ts-loader/dist/instances.js @@ -32,7 +32,7 @@ function getTypeScriptInstance(loaderOptions, loader) { return { error: configFileError }; } var configParseResult = config.getConfigParseResult(compiler, configFile, configFilePath); - if (configParseResult.errors.length) { + if (configParseResult.errors.length && !loaderOptions.happyPackMode) { utils.registerWebpackErrors(loader._module.errors, utils.formatErrors(configParseResult.errors, loaderOptions, compiler, { file: configFilePath })); return { error: utils.makeError({ rawMessage: 'error while parsing tsconfig.json', file: configFilePath }) }; } @@ -43,7 +43,10 @@ function getTypeScriptInstance(loaderOptions, loader) { // we do need to check for any issues with TS options though var program = compiler.createProgram([], compilerOptions); var diagnostics = program.getOptionsDiagnostics(); - utils.registerWebpackErrors(loader._module.errors, utils.formatErrors(diagnostics, loaderOptions, compiler, { file: configFilePath || 'tsconfig.json' })); + // happypack does not have _module.errors - see https://github.com/TypeStrong/ts-loader/issues/336 + if (!loaderOptions.happyPackMode) { + utils.registerWebpackErrors(loader._module.errors, utils.formatErrors(diagnostics, loaderOptions, compiler, { file: configFilePath || 'tsconfig.json' })); + } return { instance: instances[loaderOptions.instance] = { compiler: compiler, compilerOptions: compilerOptions, loaderOptions: loaderOptions, files: files, dependencyGraph: {}, reverseDependencyGraph: {} } }; } // Load initial files (core lib files, any files specified in tsconfig.json) |