s-panferov / awesome-typescript-loader

Awesome TypeScript loader for webpack
Other
2.35k stars 181 forks source link

Module build failed: Error: Final loader didn't return a Buffer or String #372

Open jagadeesh1492 opened 7 years ago

jagadeesh1492 commented 7 years ago

when i update the package to newer version i got this error

ERROR in ./iCommandV2/app/pages/Containers.ts
Module build failed: Error: Final loader didn't return a Buffer or String
    at D:\Jagadeesh\iCommand_V2_Upgrade\iCommandV2\Presentation\iCommand.Administration\node_modules\webpack\lib\NormalModule.js:149:64
    at D:\Jagadeesh\iCommand_V2_Upgrade\iCommandV2\Presentation\iCommand.Administration\node_modules\loader-runner\lib\LoaderRunner.js:370:3
    at iterateNormalLoaders (D:\Jagadeesh\iCommand_V2_Upgrade\iCommandV2\Presentation\iCommand.Administration\node_modules\loader-runner\lib\LoaderRunner.js:211:10)
    at iterateNormalLoaders (D:\Jagadeesh\iCommand_V2_Upgrade\iCommandV2\Presentation\iCommand.Administration\node_modules\loader-runner\lib\LoaderRunner.js:218:10)
    at D:\Jagadeesh\iCommand_V2_Upgrade\iCommandV2\Presentation\iCommand.Administration\node_modules\loader-runner\lib\LoaderRunner.js:233:3
    at context.callback (D:\Jagadeesh\iCommand_V2_Upgrade\iCommandV2\Presentation\iCommand.Administration\node_modules\loader-runner\lib\LoaderRunner.js:111:13)
    at D:\Jagadeesh\iCommand_V2_Upgrade\iCommandV2\Presentation\iCommand.Administration\node_modules\awesome-typescript-loader\src\index.ts:98:13
 @ ./iCommandV2/app/pages/container-parameter.component.ts 11:0-48
 @ ./iCommandV2/app/project/project.module.ts
 @ ./iCommandV2/app/shared/app-routing.module.ts
 @ ./iCommandV2/app/app.module.ts
 @ ./iCommandV2/main.ts
0xShammah commented 7 years ago

I have the same issue. Downgrading Typescript from 2.2.0 to 2.1.5 and awesome-typescript-loader to 3.0.0-beta.18 apparently wasn't enough for a temporary fix.

chasent commented 7 years ago

I am having the same issue. I extracted the problematic module into a seperate project, but was unable to reproduce the error again. Anyone have any suggestions on what else I can do to narrow down what exactly is going wrong here?

jagadeesh1492 commented 7 years ago

i think it's releated to this bug #320

0xShammah commented 7 years ago

I've upgraded to 3.0.4, and even deleted node_modules and invoked npm install. I still get the error, however.

[at-loader] Using typescript@2.2.0 from typescript and "tsconfig.json" from C:\Users\Roy\Documents\Visual Studio 2015\Projects\mile\StreetView\Mile.WebApp\tsconfig.release.json.

[at-loader] Checking started in a separate process...                                                                                                                            

[at-loader] Ok, 0.027 sec.                                                                                                                                                       
(node:13308) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error in plugin 'webpack-stream'                                                   
Message:                                                                                                                                                                         
    c:/users/roy/documents/visual studio 2015/projects/mile/streetview/mile.webapp/app/route/services/route-provider.ts                                                          
Module build failed: Error: Final loader didn't return a Buffer or String                                                                                                        
    at C:\Users\Roy\Documents\Visual Studio 2015\Projects\mile\StreetView\Mile.WebApp\node_modules\webpack\lib\NormalModule.js:149:64                                            
    at C:\Users\Roy\Documents\Visual Studio 2015\Projects\mile\StreetView\Mile.WebApp\node_modules\loader-runner\lib\LoaderRunner.js:370:3                                       
    at iterateNormalLoaders (C:\Users\Roy\Documents\Visual Studio 2015\Projects\mile\StreetView\Mile.WebApp\node_modules\loader-runner\lib\LoaderRunner.js:211:10)               
    at iterateNormalLoaders (C:\Users\Roy\Documents\Visual Studio 2015\Projects\mile\StreetView\Mile.WebApp\node_modules\loader-runner\lib\LoaderRunner.js:218:10)               
    at C:\Users\Roy\Documents\Visual Studio 2015\Projects\mile\StreetView\Mile.WebApp\node_modules\loader-runner\lib\LoaderRunner.js:233:3                                       
    at context.callback (C:\Users\Roy\Documents\Visual Studio 2015\Projects\mile\StreetView\Mile.WebApp\node_modules\loader-runner\lib\LoaderRunner.js:111:13)                   
    at C:\Users\Roy\Documents\Visual Studio 2015\Projects\mile\StreetView\Mile.WebApp\node_modules\awesome-typescript-loader\src\index.ts:104:13                                 
 @ c:/users/roy/documents/visual studio 2015/projects/mile/streetview/mile.webapp/app/services/backend-provider.ts 5:23-66                                                       
 @ ./app/app.module.ts                                                                                                                                                           
 @ ./app/main.tsc:/users/roy/documents/visual studio 2015/projects/mile/streetview/mile.webapp/app/route/services/preview-provider.ts                                            
Module build failed: Error: Final loader didn't return a Buffer or String                                                                                                        
    at C:\Users\Roy\Documents\Visual Studio 2015\Projects\mile\StreetView\Mile.WebApp\node_modules\webpack\lib\NormalModule.js:149:64                                            
    at C:\Users\Roy\Documents\Visual Studio 2015\Projects\mile\StreetView\Mile.WebApp\node_modules\loader-runner\lib\LoaderRunner.js:370:3                                       
    at iterateNormalLoaders (C:\Users\Roy\Documents\Visual Studio 2015\Projects\mile\StreetView\Mile.WebApp\node_modules\loader-runner\lib\LoaderRunner.js:211:10)               
    at iterateNormalLoaders (C:\Users\Roy\Documents\Visual Studio 2015\Projects\mile\StreetView\Mile.WebApp\node_modules\loader-runner\lib\LoaderRunner.js:218:10)               
    at C:\Users\Roy\Documents\Visual Studio 2015\Projects\mile\StreetView\Mile.WebApp\node_modules\loader-runner\lib\LoaderRunner.js:233:3                                       
    at context.callback (C:\Users\Roy\Documents\Visual Studio 2015\Projects\mile\StreetView\Mile.WebApp\node_modules\loader-runner\lib\LoaderRunner.js:111:13)                   
    at C:\Users\Roy\Documents\Visual Studio 2015\Projects\mile\StreetView\Mile.WebApp\node_modules\awesome-typescript-loader\src\index.ts:104:13                                 
 @ c:/users/roy/documents/visual studio 2015/projects/mile/streetview/mile.webapp/app/services/backend-provider.ts 6:25-70                                                       
 @ ./app/app.module.ts                                                                                                                                                           
 @ ./app/main.tsc:/users/roy/documents/visual studio 2015/projects/mile/streetview/mile.webapp/app/route/services/node-image-fetcher.ts                                          
Module build failed: Error: Final loader didn't return a Buffer or String                                                                                                        
    at C:\Users\Roy\Documents\Visual Studio 2015\Projects\mile\StreetView\Mile.WebApp\node_modules\webpack\lib\NormalModule.js:149:64                                            
    at C:\Users\Roy\Documents\Visual Studio 2015\Projects\mile\StreetView\Mile.WebApp\node_modules\loader-runner\lib\LoaderRunner.js:370:3                                       
    at iterateNormalLoaders (C:\Users\Roy\Documents\Visual Studio 2015\Projects\mile\StreetView\Mile.WebApp\node_modules\loader-runner\lib\LoaderRunner.js:211:10)               
    at iterateNormalLoaders (C:\Users\Roy\Documents\Visual Studio 2015\Projects\mile\StreetView\Mile.WebApp\node_modules\loader-runner\lib\LoaderRunner.js:218:10)               
    at C:\Users\Roy\Documents\Visual Studio 2015\Projects\mile\StreetView\Mile.WebApp\node_modules\loader-runner\lib\LoaderRunner.js:233:3                                       
    at context.callback (C:\Users\Roy\Documents\Visual Studio 2015\Projects\mile\StreetView\Mile.WebApp\node_modules\loader-runner\lib\LoaderRunner.js:111:13)                   
    at C:\Users\Roy\Documents\Visual Studio 2015\Projects\mile\StreetView\Mile.WebApp\node_modules\awesome-typescript-loader\src\index.ts:104:13                                 
 @ c:/users/roy/documents/visual studio 2015/projects/mile/streetview/mile.webapp/app/services/backend-provider.ts 7:27-74                                                       
 @ ./app/app.module.ts                                                                                                                                                           
 @ ./app/main.tsc:/users/roy/documents/visual studio 2015/projects/mile/streetview/mile.webapp/app/route/services/tile-image-fetcher.ts                                          
Module build failed: Error: Final loader didn't return a Buffer or String                                                                                                        
    at C:\Users\Roy\Documents\Visual Studio 2015\Projects\mile\StreetView\Mile.WebApp\node_modules\webpack\lib\NormalModule.js:149:64                                            
    at C:\Users\Roy\Documents\Visual Studio 2015\Projects\mile\StreetView\Mile.WebApp\node_modules\loader-runner\lib\LoaderRunner.js:370:3                                       
    at iterateNormalLoaders (C:\Users\Roy\Documents\Visual Studio 2015\Projects\mile\StreetView\Mile.WebApp\node_modules\loader-runner\lib\LoaderRunner.js:211:10)               
    at iterateNormalLoaders (C:\Users\Roy\Documents\Visual Studio 2015\Projects\mile\StreetView\Mile.WebApp\node_modules\loader-runner\lib\LoaderRunner.js:218:10)               
    at C:\Users\Roy\Documents\Visual Studio 2015\Projects\mile\StreetView\Mile.WebApp\node_modules\loader-runner\lib\LoaderRunner.js:233:3                                       
    at context.callback (C:\Users\Roy\Documents\Visual Studio 2015\Projects\mile\StreetView\Mile.WebApp\node_modules\loader-runner\lib\LoaderRunner.js:111:13)                   
    at C:\Users\Roy\Documents\Visual Studio 2015\Projects\mile\StreetView\Mile.WebApp\node_modules\awesome-typescript-loader\src\index.ts:104:13                                 
 @ c:/users/roy/documents/visual studio 2015/projects/mile/streetview/mile.webapp/app/services/backend-provider.ts 8:27-74                                                       
 @ ./app/app.module.ts                                                                                                                                                           
 @ ./app/main.ts                                                                                                                                                                 
jagadeesh1492 commented 7 years ago

seems to be not fixed ...

ERROR in ./xxx/app/pages/page.ts
Module build failed: Error: Final loader didn't return a Buffer or String
    at D:\Jagadeesh\xxx\xxx\Presentation\xxx.Administration\node_modules\webpack\lib\NormalModule.js:149:64
    at D:\Jagadeesh\xxx\xxx\Presentation\xxxAdministration\node_modules\loader-runner\lib\LoaderRunner.js:370:3
    at iterateNormalLoaders (D:\Jagadeesh\xxx\xxx\Presentation\xxx.Administration\node_modules\loader-runner\lib\LoaderRunner.js:211:10)
    at iterateNormalLoaders (D:\Jagadeesh\xxx\iCommandV2\Presentationxxx.Administration\node_modules\loader-runner\lib\LoaderRunner.js:218:10)
    at D:\Jagadeesh\xxx\xxx\Presentation\xxx.Administration\node_modules\loader-runner\lib\LoaderRunner.js:233:3
    at context.callback (D:\Jagadeesh\xxx\xxx\Presentation\xxx.Administration\node_modules\loader-runner\lib\LoaderRunner.js:111:13)
    at D:\Jagadeesh\xxx\xxx\Presentation\xxx.Administration\node_modules\awesome-typescript-loader\src\index.ts:104:13
 @ ./xxx/app/training/training.component.ts 15:0-37
 @ ./xxx/app/shared/component-register.module.ts
 @ ./xxx/app/app.module.ts
 @ ./xxx/main.ts
 "typescript": "2.1.6",
"awesome-typescript-loader": "3.0.4",
jagadeesh1492 commented 7 years ago

@s-panferov please reopen this issue.if you want any information are details please put up comments here..

s-panferov commented 7 years ago

@jagadeesh1492 @Shammah very interesting. Please create a repro case, because I have no idea how to reproduce this.

rexpan commented 7 years ago

This happens in my co-worker's machine but not mine. It seems it happens occasionally.

0xShammah commented 7 years ago

I'm trying to create a minimal test case by piece-wise removing functionality from our web app. I'm having some difficulty though, as it's somehow fixed out of the blue a lot of times. This is going to take some time.

0xShammah commented 7 years ago

https://github.com/Shammah/awesome-typescript-loader-error.git

I've tried to remove as much as possible from my test-case without "fixing" the error. You can checkout the repository and immediately run ./node_modules/.bin/gulp --gulpfile gulpfile.js build-app-release. This will try to compile the app, and should give the following error:

$ ./node_modules/.bin/gulp --gulpfile gulpfile.js build-app-release
[14:35:06] Using gulpfile ~\Documents\Mile.WebApp\gulpfile.js
[14:35:06] Starting 'build-app-release'...
[14:35:06] Finished 'build-app-release' after 355 ms

[at-loader] Using typescript@2.1.6 from typescript and "tsconfig.json" from C:\Users\Roy\Documents\Mile.WebApp\tsconfig.release.json.

[at-loader] Checking started in a separate process...

[at-loader] Ok, 0.004 sec.
(node:10536) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error in plugin 'webpack-stream'
Message:
    c:/users/roy/documents/mile.webapp/app/route/services/tile-image-fetcher.ts
Module build failed: Error: Final loader didn't return a Buffer or String
    at C:\Users\Roy\Documents\Mile.WebApp\node_modules\webpack\lib\NormalModule.js:149:64
    at C:\Users\Roy\Documents\Mile.WebApp\node_modules\loader-runner\lib\LoaderRunner.js:370:3
    at iterateNormalLoaders (C:\Users\Roy\Documents\Mile.WebApp\node_modules\loader-runner\lib\LoaderRunner.js:211:10)
    at iterateNormalLoaders (C:\Users\Roy\Documents\Mile.WebApp\node_modules\loader-runner\lib\LoaderRunner.js:218:10)
    at C:\Users\Roy\Documents\Mile.WebApp\node_modules\loader-runner\lib\LoaderRunner.js:233:3
    at context.callback (C:\Users\Roy\Documents\Mile.WebApp\node_modules\loader-runner\lib\LoaderRunner.js:111:13)
    at C:\Users\Roy\Documents\Mile.WebApp\node_modules\awesome-typescript-loader\src\index.ts:104:13
 @ c:/users/roy/documents/mile.webapp/app/services/backend-provider.ts 4:27-74
 @ ./app/app.module.ts
 @ ./app/main.ts

It seems to be related to the Http backend I use for testing purposes. If I remove it, it seems to work.

s-panferov commented 7 years ago

@Shammah thanks, I'll check.

sstriano commented 7 years ago

Also experiencing the same thing. ATL 3.0.7.

kkovalevskiy commented 7 years ago

I had the same issue ("Final loader didn't return a Buffer or String") under https://github.com/s-panferov/awesome-typescript-loader/issues/338. May be it reproduces not only on older versions of node, but it can depend on version of typescript?

readme42 commented 7 years ago

I had the same issue and nailed it down to be a watchpack problem. https://github.com/webpack/webpack/issues/4341

kcsahoo commented 7 years ago

Only works with ATL V2.2.4 and Typescript 2.1.1/2.0.10

BrainCrumbz commented 7 years ago

Hello all. In one of our projects we're having this issue as well, same stacktrace from awesome-typescript-loader\src\index.ts:104:13 above. @readme42 mentions an issue with watchpack, but we do not directly depend on that. Issue https://github.com/webpack/webpack/issues/4341 says that is a webpack dependency, and issue is fixed in watchpack 1.3.1.

How would you go fixing the issue, if webpack has not released an upgrade yet? Just explicitly including watchpack 1.3.1 as a dependency in our project? TA

kcsahoo commented 7 years ago

In tsconfig.json, I configured the following: "awesomeTypescriptLoaderOptions": { "useWebpackText": true, "useTranspileModule": true, "doTypeCheck": true, "forkChecker": true },

Then I am able use ATL 3.2.1 and Typescript 2.2.1 No errors.

kaminskypavel commented 7 years ago

had a similar issue , finally what did the trick was

"awesomeTypescriptLoaderOptions": { "useBabel": true, "useCache": true, "useTranspileModule": true }

Andrew565 commented 7 years ago

In the project I'm currently working on, had this same problem. Of the ATLoptions listed above, the only one required to fix the issue was "useTranspileModule". Based on what I'm seeing, this flag triggers the 'fast emit', which makes the TypeScript compiler output the 'transpiled' code instead of the 'compiled' code, which I take to mean it's just converted from TS straight to JS without all of the type-checking and re-factoring that makes TS awesome. At that point, might as well be writing in CoffeeScript or the like.

Am I correct in my analysis of what "useTranspileModule" is doing? If so, what would the appropriate steps be to try and narrow down why 'compile' is unsuccessful but 'transpile' is just fine?

guncha commented 7 years ago

I had the same issue and, after stepping through the code, saw that it was caused by the cache being stale. I had changed one of the ATL options and that should invalidate the cache, but I just saw it returning undefined for some sources. Anyway, I cleared the cache and it started working again.

ramunsk commented 7 years ago

I'm refactoring typescript application to migrate from using internal modules to external modules and also got this error. In my case i had

/// <reference path="file.ts" />
import { MyClass } from './file.ts';

Removing /// <reference ... part did the trick

"awesome-typescript-loader": "3.1.3" "typescript": "2.3.2" "webpack": "2.5.1"

HTH

EyalPerry commented 7 years ago

@kcsahoo Thank you!

s-panferov commented 7 years ago

this issue is connected with filename letter-case errors on case-insensitive file systems. need to find some workaround

Hotzilla commented 7 years ago

The issue happens in Windows when you have mixed casings in imports:

For example: import { Something } from '../Model/Something'; import { Something } from '../Model/something'; the file in the file system is called something.ts, and depending on compilation order, the .js file is created as Something.js or something.js. this will lead to "Final loader didn't return a Buffer or String" error. If you compile typescript manually with tsc, it will not fail, but you can see the case mixing in .js file names.

You will see "There are multiple modules with names that only differ in casing." warning probably at the same time.

interist32 commented 7 years ago

Just to confirm, I found that if I run the same task using console (cmd, git-bash) I am getting the error. If I run the same task using WebStorm - no error occurs at all.

interist32 commented 7 years ago

Maybe, this approach can helps? https://www.npmjs.com/package/force-case-sensitivity-webpack-plugin

pssam commented 7 years ago

I faced the same issue, cleaning .awcache folder helped me.

MadaraUchiha commented 6 years ago

Happens to me when I try to import a JS file with allowJs set to false (I expected a different error, but got this one).

Jaldeep commented 6 years ago

@Hotzilla you're right. Thanks

Trapulo commented 6 years ago

I had this error with a case error in import: import { Something } from '../Model/Something'; but the file was "something.js"...

running wepback from CLi reported the broken file

dougludlow commented 6 years ago

@MadaraUchiha - that was the issue for me. Thanks so much! (Been banging my head against the keyboard for the past couple hours...)

waratah commented 6 years ago

Just had this one. I just killed my hot update 'npm run dev' and restarted and issue disappeared. Filenames are sometimes cached causing me issues. This also causes me an issue when I use Swagger to generate a new API directory deleting the old one first. Hot update gets very confused and I have to kill 'npm run dev'

Tsourdox commented 6 years ago

Got this error after updating typescript from 2.8.x to 2.9.x. I'm using dotnet with hot module replacement (react-hot-loader) and I'm getting the error when the app hot reloads. Any one else has this issue?

chrisui commented 5 years ago

Also got this on a fresh webpack-dev-server setup. Compiling straight with webpack (same config) works but webpack-dev-server fails.

const path = require('path');

module.exports = {
  entry: './src/index.ts',
  output: {
    filename: 'bundle.js',
  },
  resolve: {
    extensions: ['.ts', '.tsx', '.js', '.jsx'],
  },
  module: {
    rules: [
      {test: /\.(t|j)sx?$/, use: {loader: 'awesome-typescript-loader'}},
      {enforce: 'pre', test: /\.js$/, loader: 'source-map-loader'},
    ],
  },
  devtool: 'source-map',
  devServer: {
    contentBase: path.join(__dirname, 'examples'),
    port: 9000,
    hot: true,
  },
};
ERROR in (webpack)/hot/dev-server.js
Module build failed: Error: Final loader (./node_modules/awesome-typescript-loader/dist/entry.js) didn't return a Buffer or String
    at runLoaders (C:\Projects\helghast\node_modules\webpack\lib\NormalModule.js:303:18)
    at C:\Projects\helghast\node_modules\loader-runner\lib\LoaderRunner.js:370:3
    at iterateNormalLoaders (C:\Projects\helghast\node_modules\loader-runner\lib\LoaderRunner.js:211:10)
    at iterateNormalLoaders (C:\Projects\helghast\node_modules\loader-runner\lib\LoaderRunner.js:218:10)
    at C:\Projects\helghast\node_modules\loader-runner\lib\LoaderRunner.js:233:3
    at context.callback (C:\Projects\helghast\node_modules\loader-runner\lib\LoaderRunner.js:111:13)
    at <anonymous>
    at runMicrotasksCallback (internal/process/next_tick.js:121:5)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)
 @ multi (webpack)-dev-server/client?http://localhost:9000 (webpack)/hot/dev-server.js ./src/index.ts main[1]
i 「wdm」: Failed to compile.

I get a slightly different error if I remove hot: true:

ERROR in (webpack)-dev-server/client?http://localhost:9000
Module build failed: Error: Final loader (./node_modules/awesome-typescript-loader/dist/entry.js) didn't return a Buffer or String
    at runLoaders (C:\Projects\helghast\node_modules\webpack\lib\NormalModule.js:303:18)
    at C:\Projects\helghast\node_modules\loader-runner\lib\LoaderRunner.js:370:3
    at iterateNormalLoaders (C:\Projects\helghast\node_modules\loader-runner\lib\LoaderRunner.js:211:10)
    at iterateNormalLoaders (C:\Projects\helghast\node_modules\loader-runner\lib\LoaderRunner.js:218:10)
    at C:\Projects\helghast\node_modules\loader-runner\lib\LoaderRunner.js:233:3
    at context.callback (C:\Projects\helghast\node_modules\loader-runner\lib\LoaderRunner.js:111:13)
    at <anonymous>
    at runMicrotasksCallback (internal/process/next_tick.js:121:5)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)
 @ multi (webpack)-dev-server/client?http://localhost:9000 ./src/index.ts main[0]
i 「wdm」: Failed to compile.
Levertion commented 5 years ago

I'm also getting this issue. Note that it should possibly be an upstream typescript bug, and the same issue as TypeStrong/ts-loader#568.

I'm getting reproduction on my npmsupport branch, and was also getting a reproduction of TypeStrong/ts-loader#568 when using ts-loader.

Permalink in case branch is deleted.

Grewer commented 5 years ago

Tested it Use "typescript": "^3.1.6" to compile successfully Using "typescript": "^3.2.2" + "useTranspileModule":true is also successful

hrc7505 commented 5 years ago

I am also suffering from the same problem.

limbosounds commented 4 years ago

Still having this problem

"awesome-typescript-loader": "5.2.1",
"typescript": "3.6.4",
"superagent": "5.1.0"

Error is being produced by superagent. Just importing it and doing the GET

import Superagent from "superagent"

Superagent.get("/kappa")