Giter VIP home page Giter VIP logo

Comments (5)

medikoo avatar medikoo commented on June 7, 2024

@kaerus Best way is not to mix strictly server and strictly client side logic within one module, also module that aims to be cross-environment (for client and server) should not incorporate strictly server-side logic, it should be separate modules.

Different case is when module is about providing one functionality (one API), but for that it needs to address totally different API's in different environments, good example is microtime-x, in such case I write node-only requires as (require)('path'), so they're not picked by webmake

But I feel that in your case, you should provide two separate start point modules for server and for client, so server one includes http module and client one does Ajax. Does it answer your issue?

from modules-webmake.

 avatar commented on June 7, 2024

@medikoo If you mean I can do like this

if(!BROWSER) ajax = (require)('http').request;
else ajax = require('./ajax');

Yes that would definitely answer my issue. :)

Both libraries provide roughly the same API.

Wow, it looks good so far!

K1:arango-client kaerus$ webmake --name arango.client  ./index.js ./dist/arango.js
Done [18 modules from 1 packages in 0.02s]

from modules-webmake.

medikoo avatar medikoo commented on June 7, 2024

@kaerus yes, exactly :)

If this module is about providing same functionality no matter where it's executed, then it's exactly what you should do.

from modules-webmake.

 avatar commented on June 7, 2024

Great!
It sure looks good at first glance.
I'll evaluate this a little more and perhaps get back with more questions.

from modules-webmake.

medikoo avatar medikoo commented on June 7, 2024

Good, let me know.

from modules-webmake.

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.