Coder Social home page Coder Social logo

Comments (10)

JanKaul avatar JanKaul commented on May 29, 2024 3

I think I have the same problem with popper.js. The program fails to load:

var _popper = _interopRequireDefault(require("popper.js"));

When I bundle it with webpack, it works fine.

from moduleserve.

ochrons avatar ochrons commented on May 29, 2024 2

This popped up due to Reason React quick-start template starting to use moduleserve (instead of webpack dev server), and Ant Design depending on omit.js, so the combo didn't work. So there might more users to moduleserve in the future due to this Reason connection :)

from moduleserve.

hunterwilliams avatar hunterwilliams commented on May 29, 2024 1

We've got the same issue with our demo page for bs-mui (material ui); Pointing it to 7db414e makes it work.

from moduleserve.

marijnh avatar marijnh commented on May 29, 2024

Could you see if attached patch helps for you?

from moduleserve.

ochrons avatar ochrons commented on May 29, 2024

It doesn't seem to help. I think the problem is already in generating the request, as I'm seeing:

http://localhost:8000/moduleserve/mod/src/Index.bs/__mod/omit

which is already missing the .js suffix. Perhaps because of client.js

      var resp = get(base + name.replace(/(^|\/)\.\.(?=$|\/)/g, "$1__").replace(/\.js$/, ""))

from moduleserve.

marijnh avatar marijnh commented on May 29, 2024

Ah, right, I only tested with curl, didn't actually go through the client.

That is a more complicated problem, since the client doesn't have the information needed to figure out whether a given module name can be safely normalized.

This system of normalization is intended to reduce the amount of requests the loader has to make—we need to address every module via a canonical URL to make caching (HTTP caching as well as local module instance caching) work. The assumption is that most modules will be require-d with a suffix-less name, so the server considers those names to be their canonical URL, to avoid an extra redirect for such names.

That turns out to be problematic. I expect it does avoid a lot of requests in typical code, but it is unclear how to work around this issue with it.

I'm probably not going to put more time into searching for a solution, since this is just a package that I use as a utility in some of my projects, and none of these projects have this issue. But if you have ideas for solution, let me know.

from moduleserve.

ochrons avatar ochrons commented on May 29, 2024

If I look at the resolving algorithm at https://nodejs.org/api/modules.html#modules_all_together there is no dropping of .js suffix when loading modules. So is that even needed?

from moduleserve.

marijnh avatar marijnh commented on May 29, 2024

As I mentioned above, it's a hack to reduce the number of requests.

from moduleserve.

mcanobbio avatar mcanobbio commented on May 29, 2024

I have the same problem with popper.js that is being used by material-ui

from moduleserve.

smh avatar smh commented on May 29, 2024

@marijnh: just a note, I had the same issue with dinero.js (through react-dinero). Switching to 7db414e solved it for me, albeit with an extra request (well worth it to me).

from moduleserve.

Related Issues (5)

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.