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

Passing context as configFileName to tsImpl.parseJsonConfigFileContent may cause whole disk scan

Open SyuTingSong opened this issue 7 years ago • 0 comments

The function readConfigFile in file src/instance.ts pass the argument context as both basePath and configFileName parameters to parseJsonConfigFileContent.

https://github.com/s-panferov/awesome-typescript-loader/blob/ed5d1a3ac9653b6dd21e22cfd51e99e38c62c50a/src/instance.ts#L322

The constructor of class PathPlugin use process.cwd() as context as fallback value, which is a directory, not a file.

Since parseJsonConfigFileContent will recursively scan both of the basePath and the dirname of configFileName, passing context as configFileName would mislead the typescript compiler scan files outside the basePath.

The worst case is that running scripts in some directory under root. e.g. /web. In such case the typescript compiler recursively scan the whole root. It will never stop on Linux, because the linux /proc has cycle ref dirs.

SyuTingSong avatar Apr 25 '18 06:04 SyuTingSong