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

Cannot be used in webpack/browser, due to require("fs") #157

Open
Venryx opened this issue Oct 23, 2019 · 1 comment
Open

Cannot be used in webpack/browser, due to require("fs") #157

Venryx opened this issue Oct 23, 2019 · 1 comment

Comments

@Venryx
Copy link

Venryx commented Oct 23, 2019

Most of this library works perfectly fine between NodeJS and the browser/Webpack.

However, there is one line that breaks it for the latter: https://github.com/soumak77/firebase-mock/blob/master/src/storage-file.js#L8

Ideally, there would be a way to exclude the NodeJS-requiring portion of the library, so you can use it from browser code.

This would be helpful because it means I can more easily integrate the mocking library with Cypress. (Cypress tests run in the browser alongside the main application code)

@Venryx
Copy link
Author

Venryx commented Oct 23, 2019

For now I'm getting around the issue by adding fs to Webpack's externals config:

webpackConfig.externals = {
	// needed for firebase-mock in browser (code-path not actually used, so it's okay)
	fs: 'root location', // redirect to some global-variable, eg. window.location
};

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

1 participant