Should recognize and handle UNC path on Windows correctly
In pathToArray function, if the path looks like \\SERVER\folder\subfolder\abc.txt, it will throw MemoryFileSystemError(errors.code.EINVAL, path).
This is causing issues with Node.js >= 6.0.0 when bundling with Webpack on a UNC path.
Repro steps:
- Mapped
\\SERVER\foldertoZ: - Setup a
webpack.config.jsthat has anentrybased on__dirname
Expected: Webpack should bundle successfully
Actual:
Node.js >= 6.0.0: Webpack failed because pathToArray does not recognize UNC path
Node.js < 6.0.0: Bundle successfully
This is because under Node.js >= 6.0.0. Any JS modules on a mapped drive Z:, the __dirname will be relative to \\SERVER\folder\, instead of Z:\. And Webpack will fail because memory-fs could not recognize UNC path correctly.
There is currently no workaround as the new behavior on __dirname is consistent across all modules. The only way is to use process.cwd() instead but the solution is limited.
This is a blocking issue for Webpack bundler to run on Azure Web App with Node.js >= 6.0.0.
The correct behavior of pathToArray should be recognizing \\SERVER\folder and turn it into ['\\SERVER', 'folder'].
yep, it should handle these paths. PR?