Skip to content
This repository has been archived by the owner on Dec 1, 2019. It is now read-only.

When use an empty xxx.d.ts,at-loader will throw an exception #320

Open
hstarorg opened this issue Dec 15, 2016 · 8 comments
Open

When use an empty xxx.d.ts,at-loader will throw an exception #320

hstarorg opened this issue Dec 15, 2016 · 8 comments

Comments

@hstarorg
Copy link

Maybe it is typescript bug.

@hstarorg hstarorg changed the title When use a empty xxx.d.ts,at-loader will throw an exception When use an empty xxx.d.ts,at-loader will throw an exception Dec 15, 2016
@rcollette
Copy link

rcollette commented Jan 5, 2017

I can't speak to the latest beta version, but prior versions add an "opinion" that generated empty files are in some way a bug whereas the tsc compiler does not. I don't know if this is related.

I would suggest that in the upcoming version, such added behavior not be included. If tsc doesn't consider it an error, why should a loader.

Our older gulp builds used to filter out interface only files (.I.js) because they would be empty. Such an option for empty output files would be welcome, since we have little other control, to my knowledge, of file handling in a manner similar to a gulp pipeline.

@hstarorg
Copy link
Author

hstarorg commented Jan 6, 2017

Some error info:

ERROR in ./src/modules/nk-demo/index.ts
Module build failed: Error: Final loader didn't return a Buffer or String
    at D:\TeamCode\newkit\node_modules\webpack\lib\NormalModule.js:151:64
    at D:\TeamCode\newkit\node_modules\loader-runner\lib\LoaderRunner.js:365:3
    at iterateNormalLoaders (D:\TeamCode\newkit\node_modules\loader-runner\lib\LoaderRunner.js:206:10)
    at iterateNormalLoaders (D:\TeamCode\newkit\node_modules\loader-runner\lib\LoaderRunner.js:213:10)
    at D:\TeamCode\newkit\node_modules\loader-runner\lib\LoaderRunner.js:228:3
    at context.callback (D:\TeamCode\newkit\node_modules\loader-runner\lib\LoaderRunner.js:106:13)
    at process._tickDomainCallback (internal/process/next_tick.js:129:7)

The empty file is created by myself. It's not a common case.
In the version 3.0.0-beta.17, the same problem.

@hstarorg
Copy link
Author

hstarorg commented Jan 6, 2017

set content

export {};

to the empty xx.d.ts, will shy away this problem.

@claudiuconstantin
Copy link

I am also encountering this error:

ERROR in ./test/test2/test3/file.ts
Module build failed: Error: Final loader didn't return a Buffer or String
[...]

with the following package versions:

"devDependencies": {
 [...]
 "awesome-typescript-loader": "^3.0.3",
 "typescript": "^2.1.0",
 "webpack": "^2.2.1",
 [...]
}

Any ideas why this is happening?

@hstarorg
Copy link
Author

@claudiuconstantin some d.ts is empty will throw the messages.

@s-panferov
Copy link
Owner

It seems to be a bug in TypeScript

@s-panferov
Copy link
Owner

I've finally understood what is going on. Please confirm my thoughts.

Repro case:

index.ts:

import './empty.d.ts'

This will be transpiled by typescript into:

index.js:

require('./empty.d.ts')

Then webpack tries to load index.d.ts with atl, because it has .ts extension. But loader can't emit .d.ts, this is no-op.

I'll make a hack in the loader to emit empty modules in such cases, but actually, this should never happen, because import './empty.d.ts' should instead be written as import './empty';

@ghost
Copy link

ghost commented Jan 8, 2018

I have the same issue please help me(urgent)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants