-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Library failing to work in the browser due to fs.readFile #1775
Comments
Is there a workaround for this? |
@ihodes we've fixed this issue in a few upstream libraries before, but it's a bit of a losing battle until we get slightly better integration tests in place. Have labeled this as a bug, which I think is appropriate 👍 I'd like us to start introducing webpackablility as one of the integration tests for a variety of our libraries. |
@bcoe would you recommend people do something different in the meantime because this could take a while to fix (and if so, what would you recommend?) or will this be fixed so soon that you'd recommend just waiting? |
I'm stuck with this issue too. Any workaround till fix is stable? |
Same here |
@ihodes does adding something like the following to your module.exports = {
resolve: {
extensions: ['.js'],
alias: {
fs: path.resolve(__dirname, 'src/mock-fs.js')
}
}
}; where module.exports = {
readFileSync () {}
} |
@bcoe This worked for me, except for one thing, it crashes on Side note: I'm using
|
@ihodes does this approach work for you as well? |
Apologies, I've moved my work to the backend for now, so don't have an easy way to test this, but would imagine it would as well. Thank you for finding a work-around, though! |
I also experience this issue and I had to replace |
Unfortunately due to googleapis/google-api-nodejs-client#1775, I have to source the google API from the web directly, without using the googleapis package. Sadly, this means no type annotations :(
@abohomol one of our users wrote this blog post on the topic of webpacking our libraries: https://blog.angularindepth.com/google-apis-with-angular-214fadb8fbc5 I think it's a good starting point for running |
Thanks! this work for me on Quasar Framework in const path = require('path')
// ...
cfg.resolve.alias = {
...cfg.resolve.alias, // This adds the existing alias
fs: path.resolve(__dirname, 'src/mock-fs.js')
} The module.exports = {
readFile () {}
} |
@abohomol same issue |
Check my solution! |
I"m trying to use this library in the browser, which I think is supported, but the
googleapis-common
library uses the Node.jsfs
library (and readFile, in particular, here https://github.com/googleapis/nodejs-googleapis-common/blob/master/src/discovery.ts#L27) and this causes it not to work in the browser.The beginning of the stack trace is as follows (rest in this gist):
Environment details
googleapis
version: 41.0.1Steps to reproduce
import { google } from 'googleapis';
in an app being packaged for the browserconsole.log(google);
somewhereThe text was updated successfully, but these errors were encountered: