Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatibility with node fs api. #89

Closed
alexander-akait opened this issue Jun 9, 2017 · 5 comments
Closed

Incompatibility with node fs api. #89

alexander-akait opened this issue Jun 9, 2017 · 5 comments

Comments

@alexander-akait
Copy link
Member

I'm not sure this is bugs or expected behavior.
Example: fileSystem.readFileSync(filename, "utf8"), not respect utf8 and always return Buffer.

@TheLarkInn
Copy link
Member

What version of node did you see this?

@alexander-akait
Copy link
Member Author

@TheLarkInn i see function as in fs module (readFileSync and etc), It would be nice to have compatibility them with nodejs fs.
Original issue: babel/babel-loader#460 , maybe give more information.

@mhink
Copy link

mhink commented Jun 22, 2018

@TheLarkInn I ran into this as well. (For reference, the error I was seeing is the same as this one in CopyWebpackPlugin: webpack-contrib/copy-webpack-plugin#217)

The incompatibility is in this method call (and others like it)

https://github.com/webpack/enhanced-resolve/blob/master/lib/CachedInputFileSystem.js#L238

The method signature here is readFile(path, callback), but Node's fs methods have the signature readFile(path, options, callback) as documented in the following:

https://nodejs.org/dist/latest-v8.x/docs/api/fs.html#fs_fs_readfile_path_options_callback

So if you're doing something like fs.readFile(pathToMyFile, "utf8", callback), CachedInputFileSystem tries to invoke "utf8" as a callback, and throws:

TypeError: callbacks[i] is not a function

@rjgotten
Copy link

Hitting this as well in the context of writing a loader for Webpack.

Really annoying and makes it awfully tempting to sidestep the formally correct this.fs and just directly hit the raw Node.js internal fs module instead.

@alexander-akait
Copy link
Member Author

Fixed before, improved here #254

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

No branches or pull requests

4 participants