GithubHelp home page GithubHelp logo

Comments (5)

AndreasMadsen avatar AndreasMadsen commented on July 21, 2024

This is a really good usecase for not having a throw. However an actual roll back (git revert) seams like a bad idea, removing the line and change the tests to the opposite (tests that require don't throw) would be much better. Also this should be done for all the unimplemented modules not just fs.

Another solution would be to have a browser-builtins specific method there tells the unimplemented modules that they have been implemented in an untraditional way and shouldn't throw.

process.implement('fs');
var fs = require('fs'); // should not throw

I would prefer the first, since that browser-builtins specific methods makes porting things to the browser become a two way compatibility issue.

I will fix this tomorrow or in the weekend if no body else dose it before me.

from node-browser-builtins.

thlorenz avatar thlorenz commented on July 21, 2024

I actually think a revert would be fine. I mean what would you test - that requiring a file with no code doesn't throw?

If reverting is not ok, my fix would be to remove the test and remove the line that throws (which is essentially a revert). If that is ok, I can do that today and hopefully get this published ASAP, as this will affect everyone using brfs as soon as they upgrade browserify.

In general, no builtin should ever throw when required. If you want to warn users of missing functionality you may throw when they call an unimplemented method, but not before that.
Otherwise lots of other things may break as well.

from node-browser-builtins.

AndreasMadsen avatar AndreasMadsen commented on July 21, 2024

that requiring a file with no code doesn't throw?

Yes exactly. Whatever implementation there overwrites fs should be able to require the fs module. If the fs.js file is removed (empty files are likely to be removed) that will also throw on require.

I can do that today and hopefully get this published ASAP, as this will affect everyone using brfs as soon as they upgrade browserify.

I can understand that, but please be nice. This is a big update and browser-builtins even got a major version bump and it is a basically unknown repository there get very little feedback so there ought to be some issues.

from node-browser-builtins.

thlorenz avatar thlorenz commented on July 21, 2024

I get that later down the line you may want to add tests back in (for empty files), but at this point the test serves no purpose, so I hope removing it is ok.

I cannot see a way that not throwing could be a regression and/or break existing code. Also lots of code aside from brfs may break due to throwing (we may not be aware of it yet since some peeps may not have upgraded their browserify in a month).

Therefore I think this fixes regressions rather than introducing them and should be published as a patch to unbreak everyone who depends on brfs for instance.
So even if you have other plans on how this will work in the future I believe it is very important to provide this fix in the meantime.

from node-browser-builtins.

AndreasMadsen avatar AndreasMadsen commented on July 21, 2024

So even if you have other plans on how this will work in the future I believe it is very important to provide this fix in the meantime.

My plans are stability and maintainability, I think both are partially done by being strict about adding tests when something fail. Also I added a pull request there fixes all the unimplemented modules and the tests.

from node-browser-builtins.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.