awesome-typescript-loader icon indicating copy to clipboard operation
awesome-typescript-loader copied to clipboard

Fails when upgrading to typescript >= 3.2.1

Open basslagter opened this issue 6 years ago • 13 comments

When upgrading to Typescript 3.2.1 I get "Module build failed: Error: Final loader (./node_modules/awesome-typescript-loader/dist/entry.js) didn't return a Buffer or String"

basslagter avatar Dec 03 '18 13:12 basslagter

Agreed, I had to roll back to 3.1.6 to get it to compile correctly

dl748 avatar Dec 03 '18 17:12 dl748

Same here

basslagter avatar Dec 03 '18 18:12 basslagter

TS v3.2.2 also has an issue.

Ky6uk avatar Dec 10 '18 13:12 Ky6uk

Yepp, just experienced the same

basslagter avatar Dec 10 '18 14:12 basslagter

For the record, this is the error we get when building. The Final loader (...) didn't return a Buffer or String error does not show up here as it only shows up on re-builds:

$ yarn build
yarn run v1.7.0
$ webpack --mode development
ℹ 「atl」: Using [email protected] from typescript
ℹ 「atl」: Using tsconfig.json from /.../tsconfig.json
ℹ 「atl」: Checking started in a separate process...
✖ 「atl」: Child process failed to process the request: Error: Debug Failure. Invalid cast. The supplied value [object Object] did not pass the test 'isJsonSourceFile'.
    at Object.cast (/.../node_modules/typescript/lib/typescript.js:1325:22)
    at getTypeOfVariableOrParameterOrPropertyWorker (/.../node_modules/typescript/lib/typescript.js:35591:41)
    at getTypeOfVariableOrParameterOrProperty (/.../node_modules/typescript/lib/typescript.js:35567:48)
    at getTypeOfSymbol (/.../node_modules/typescript/lib/typescript.js:35856:24)
    at resolveESModuleSymbol (/.../node_modules/typescript/lib/typescript.js:32928:36)
    at getTargetOfNamespaceImport (/.../node_modules/typescript/lib/typescript.js:32431:20)
    at getTargetOfAliasDeclaration (/.../node_modules/typescript/lib/typescript.js:32560:28)
    at resolveAlias (/.../node_modules/typescript/lib/typescript.js:32595:30)
    at checkAliasSymbol (/.../node_modules/typescript/lib/typescript.js:55749:26)
    at checkImportBinding (/.../node_modules/typescript/lib/typescript.js:55778:13)
    at checkImportDeclaration (/.../node_modules/typescript/lib/typescript.js:55796:29)
    at checkSourceElement (/.../node_modules/typescript/lib/typescript.js:56151:28)
    at Object.forEach (/.../node_modules/typescript/lib/typescript.js:210:30)
    at checkSourceFileWorker (/.../node_modules/typescript/lib/typescript.js:56305:20)
    at checkSourceFile (/.../node_modules/typescript/lib/typescript.js:56277:13)
    at getDiagnosticsWorker (/.../node_modules/typescript/lib/typescript.js:56352:17)
    at Object.getDiagnostics (/.../node_modules/typescript/lib/typescript.js:56338:24)
    at /.../node_modules/typescript/lib/typescript.js:87001:85
    at runWithCancellationToken (/.../node_modules/typescript/lib/typescript.js:86967:24)
    at getSemanticDiagnosticsForFileNoCache (/.../node_modules/typescript/lib/typescript.js:86990:20)
    at getAndCacheDiagnostics (/.../node_modules/typescript/lib/typescript.js:87238:26)
    at getSemanticDiagnosticsForFile (/.../node_modules/typescript/lib/typescript.js:86987:20)
    at getDiagnosticsHelper (/.../node_modules/typescript/lib/typescript.js:86929:24)
    at Object.getSemanticDiagnostics (/.../node_modules/typescript/lib/typescript.js:86942:20)
    at getSemanticDiagnosticsOfFile (/.../node_modules/typescript/lib/typescript.js:89025:41)
    at Object.getSemanticDiagnosticsOfNextAffectedFile (/.../node_modules/typescript/lib/typescript.js:89187:52)
    at processDiagnostics (/.../node_modules/awesome-typescript-loader/src/checker/runtime.ts:513:22)
    at /.../node_modules/awesome-typescript-loader/src/checker/runtime.ts:613:6
    at Object.send (/.../node_modules/awesome-typescript-loader/src/checker/runtime.ts:49:6)
    at Checker.req (/.../node_modules/awesome-typescript-loader/src/checker/checker.ts:100:15)
Hash: 7ffd5886c56e982a9956
Version: webpack 4.25.1
Time: 13318ms
Built at: 12/14/2018 3:01:18 PM
                           Asset      Size  Chunks             Chunk Names
                      index.html   409 KiB          [emitted]
    main.45e61292c73d720513b1.js  8.74 MiB    main  [emitted]  main
main.45e61292c73d720513b1.js.map  9.65 MiB    main  [emitted]  main
Entrypoint main = main.45e61292c73d720513b1.js main.45e61292c73d720513b1.js.map
[0] ../locale-data/index.js (ignored) 15 bytes {main} [built]
[1] ./lib/locales (ignored) 15 bytes {main} [built]
[2] ./lib/locales (ignored) 15 bytes {main} [built]
[./node_modules/webpack/buildin/global.js] (webpack)/buildin/global.js 489 bytes {main} [built]
[./node_modules/webpack/buildin/harmony-module.js] (webpack)/buildin/harmony-module.js 573 bytes {main} [built]
[./node_modules/webpack/buildin/module.js] (webpack)/buildin/module.js 497 bytes {main} [built]
[./src/index.tsx] 412 bytes {main} [built]
[./src/translations.ts] 45 bytes {main} [built]
    + 960 hidden modules
Child html-webpack-plugin for "index.html":
     1 asset
    Entrypoint undefined = index.html
    [./node_modules/html-webpack-plugin/lib/loader.js!./views/index.html.tpl] 1.4 KiB {0} [built]
    [./node_modules/webpack/buildin/global.js] (webpack)/buildin/global.js 489 bytes {0} [built]
    [./node_modules/webpack/buildin/module.js] (webpack)/buildin/module.js 497 bytes {0} [built]
        + 3 hidden modules
✨  Done in 14.44s.

Here is the (minimal) Webpack configuration that led to this:

import webpack from 'webpack';

const config: webpack.Configuration = {
  resolve: {
    extensions: ['.js', '.json', '.ts', '.tsx'],
  },
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        exclude: /node_modules/,
        loader: 'awesome-typescript-loader',
      },
    ],
  },
  devtool: 'source-map',
};

export default config;

What tricked us is that even though the output said ✖ 「atl」: Child process failed to process the request, the build did not return a non-zero code, so our CI passed just fine. It would be very useful if any failure from a child process would fail the build.

astorije avatar Dec 14 '18 20:12 astorije

It works for me with following config (tsconfig.json):

  "awesomeTypescriptLoaderOptions": {
    "useTranspileModule": true
  }

bitworking avatar Jan 02 '19 12:01 bitworking

@bitworking what effect does this have on the output?

Also...for me it works on the first compile but fails with HMR whenever I edit a file in development.

basslagter avatar Jan 02 '19 14:01 basslagter

@basslagter Yes you are right..a live reload doesn't work for me either. I didn't examine the output if there's a difference but from the docs it only uses a fast transpileModule emit mode.

bitworking avatar Jan 02 '19 16:01 bitworking

I'm now using ts-loader: https://github.com/TypeStrong/ts-loader/blob/master/examples/hot-module-replacement/webpack.config.js

bitworking avatar Jan 03 '19 09:01 bitworking

@bitworking yes, I am also thinking about switching. This package does not seem to be maintained anymore. Thanks!

basslagter avatar Jan 03 '19 09:01 basslagter

That's funny but ts-loader isn't working in my case without this package because of issue #1 in tsconfig-paths-webpack-plugin. So I switched to ts-loader and I'm currently using a-t-l only for proper paths handling by using TsConfigPathsPlugin exported from it. 🤔

Ky6uk avatar Jan 09 '19 14:01 Ky6uk

encounter the same problem.

maybe I should be switch ts-loader too.

kaimiyang avatar Feb 08 '19 00:02 kaimiyang

@bitworking - this link doesn't work anymore - you wouldn't happen to be able to get a working URL could you?

smokinjoe avatar Mar 21 '19 20:03 smokinjoe