Git Product home page Git Product logo

Comments (9)

domenic avatar domenic commented on May 26, 2024 1

I am on vacation through April 1, but would be happy to review PRs clarifying this or other aspects in the meantime.

from import-maps.

justinfagnani avatar justinfagnani commented on May 26, 2024

Since a scope defines a path and is a prefix of the refererURL, it makes sense to me that paths within a scope are relative to the path of the scope.

As you point out, you can refer outside of the scope path by using ../:

{
  "path_prefix": "https://foo.bar",
  "packages": {
    "A": { "path": "A@1", "main": "index.js" },
    "B": { "path": "B@1", "main": "index.js" }
  },
  "scopes": {
    "A": {
      "packages": {
        "C": { "path": "../C@1", "main": "index.js" }
      }
    },
    "B": {
      "packages": {
        "C": { "path": "../C@2", "main": "index.js" }
      }
    }
  }
}

from import-maps.

arcanis avatar arcanis commented on May 26, 2024

I find it really confusing, especially considering that this rule behavior is ambiguous in itself. Module names are not strictly correlated to the filesystem paths, so why make the scopes package paths relative to the scope names rather than the scopes paths? ie has a user, I could expect the following:

https://foo.bar/A@1/C@2/index.js
https://foo.bar/B@1/C@2/index.js

But not really this, since I never specified that A and B were valid URLs:

https://foo.bar/A/C@2/index.js
https://foo.bar/B/C@2/index.js

I can guess that the main argument for this behavior is that it's much simpler to just use the scope name rather than the package paths, but my point is that automatically composing path is a confusing behavior in itself, which counterbalances the "less repetition" argument. I'd prefer things to be explicit rather than implicit and subject to varying expectations.

from import-maps.

justinfagnani avatar justinfagnani commented on May 26, 2024

Scopes are independent from packages and don't have names - they are very explicitly and only paths. The reason is the role of a scope: it's used to look up a map based on the refererURL.

from import-maps.

arcanis avatar arcanis commented on May 26, 2024

I'm not sure I understand. Does that make my example above wrong, and should be this instead: ?

{
  ...,
  "scopes": {
    "A@1": {
       ...,
    },
    "B@1": {
       ...,
    }
  }
}

from import-maps.

justinfagnani avatar justinfagnani commented on May 26, 2024

Ah, yes. Though we should be careful to be clear with statements like "Resolving C from A". The "from" part really should be a path to be most clear.

from import-maps.

arcanis avatar arcanis commented on May 26, 2024

I see - if the scopes keys are URLs/paths, then I think the relative behavior semantically makes much more sense, thanks!

from import-maps.

justinfagnani avatar justinfagnani commented on May 26, 2024

cc @domenic for the discussion. Emphasizing that scopes are path-keyed and never referring to "scope name" would probably be helpful.

from import-maps.

guybedford avatar guybedford commented on May 26, 2024

This tripped me up too and seems like a common catch from the way the examples are described.

from import-maps.

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.