Git Product home page Git Product logo

Comments (8)

domenic avatar domenic commented on June 1, 2024

QuickStart should not try to follow browser fields that do not appear in program code.

from asap.

kamicane avatar kamicane commented on June 1, 2024

The thing is, it cannot know if the browser key does not appear in the program code, short of making browser keys absolute paths only (which, by the way goes against the proposed spec).

Say you route "a": "b", and you require("c") I need to first resolve "c" (say it resolves to "SOME_PATH/c.js") and then I need to resolve "a" too, to see if it resolves to "SOME_PATH/c.js" also, which it totally could, since there could be another browser key rule down the require line to make that happen.

from asap.

domenic avatar domenic commented on June 1, 2024

Whatever browserify does, you should do.

from asap.

kamicane avatar kamicane commented on June 1, 2024

Even if the approach is not "correct" though?

Another easier example to show the logic around this:

in package.json

"browser": {
  "./folder": "./folder-browser.js"
}

your package ./lib/file

`require("../folder")`

The "correct" approach is to resolve "../folder" first (which, say, resolves to "./folder/file.js") then look at browser, and resolve "./folder" to see if it resolves to "./folder/file.js" and if a match is found, route it to "./folder-browser.js".

The Browserify approach is to simply not allow the key-part of the browser field to be resolveable, therefore in Browserify, this needs to be the package.json:

"browser": {
  "./folder/file.js": "./folder-browser.js"
}

from asap.

domenic avatar domenic commented on June 1, 2024

Compatible is correct. Incompatible is incorrect.

from asap.

kamicane avatar kamicane commented on June 1, 2024

I don't necessarily disagree about compatibility, but we digress. The route is still invalid, and having an invalid route in the project just because Browserify is relaxed about routes is a bit meh. The real issue is not how Browserify calculates routes, the real issue is that Browserify does not care if a route does not exist. I was trying to explain why all routes should be resolvable from a logical point of view.

from asap.

domenic avatar domenic commented on June 1, 2024

The route is resolvable in development, which is one scenario in which browserify is used. It is not resolvable when used as a dependency, which is another scenario in which browserify is used. The browser field spec chose not to create separate "browserDev" and "browser" fields, but instead to just be relaxed about how it works.

from asap.

kriskowal avatar kriskowal commented on June 1, 2024

Adding tests back to the deployed package is not an option. I am sympathetic to the issue, but it is worth pushing back on incompatible tooling in this case.

from asap.

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.