Giter Site home page Giter Site logo

Comments (9)

guybedford avatar guybedford commented on July 16, 2024 2

And to support all the aliases:

jspm install --provider esm.sh react/jsx-runtime=preact react-dom/test-utils=preact react=preact/compat react-dom=preact/compat -r react=npm:preact -r react-dom=npm:preact

The react/jsx-runtime=preact is probably also a bug - in that we should require explicit aliasing of the exact install, as opposed to inferring the path into the target.

from jspm-cli.

guybedford avatar guybedford commented on July 16, 2024 1

Try the following, and let me know how far you get with this:

jspm install --provider esm.sh react=preact/compat react-dom=preact/compat -r react=npm:preact -r react-dom=npm:preact

Resolutions only behave at the package level (more like npm resolutions), that react=preact/compat was working is really a bug - it's important that these are always package to package mappings.

So we use both techniques because you want to both lock the dependencies and also alias the entry point.

from jspm-cli.

guybedford avatar guybedford commented on July 16, 2024 1

And here's an even simpler command:

jspm install --provider esm.sh react/jsx-runtime react-dom/test-utils react=react/compat react-dom=react/compat -r react=npm:preact -r react-dom=npm:preact

from jspm-cli.

schlichtanders avatar schlichtanders commented on July 16, 2024

I stumbled upon the resolution flag which seems to be the option to solve these alias problems

However, it does not work with submodules, which are needed for the correct aliases of preact. I guess this problem is similar to the problems with submodules using plain jspm install alias=package described above.

$ jspm install --provider esm.sh -r react=preact/compat -r react-dom=preact/compat
Error: Unable to resolve npm:preact/compat@ to a valid version imported from file:///home/myhome/myproject/

Also note that the resolution documentation aliases react to preact, which is wrong according to preact alias documentation

from jspm-cli.

schlichtanders avatar schlichtanders commented on July 16, 2024

that react=preact/compat was working is really a bug - it's important that these are always package to package mappings.

This surprises me slightly. I was assuming that --resolution could work similar to aliasing so that also subpackages could be remapped. But if the functionality is fully there also without this, I am super happy.

EDIT: Wait, I think I overlooked this. How is the package to package mapping resolving preact alias correctly? There it is a package to subpackage mapping, isn't it?

The react/jsx-runtime=preact is probably also a bug - in that we should require explicit aliasing of the exact install, as opposed to inferring the path into the target.

I agree. I am always expecting a plain mapping without any magic.

from jspm-cli.

schlichtanders avatar schlichtanders commented on July 16, 2024

I tested it now, and it fails as far as I can see

running

jspm install --provider esm.sh react/jsx-runtime=preact react-dom/test-utils=preact react=preact/compat react-dom=preact/compat -r react=npm:preact -r react-dom=npm:preact

results in

imports: {
    "react-dom/compat": "https://esm.sh/*[email protected]/compat",
    "react-dom/test-utils": "https://esm.sh/*[email protected]/test-utils",
    "react/compat": "https://esm.sh/*[email protected]/compat",
    "react/jsx-runtime": "https://esm.sh/*[email protected]/jsx-runtime",
},
"scopes": {
    "https://esm.sh/": {
        ....
        "react": "https://esm.sh/*[email protected]",
        "react-dom": "https://esm.sh/*[email protected]",
        ...
    },
}

which on both sides is wrong - react (the package) needs to point to preact/compat (the subpackage)

from jspm-cli.

schlichtanders avatar schlichtanders commented on July 16, 2024

Also I actually don't need it in the import section, as I am not importing react myself. It is really just needed within the scopes, for my case, as I want to use material-ui which by default uses react, but should use the same preact version

from jspm-cli.

schlichtanders avatar schlichtanders commented on July 16, 2024

@guybedford can you help? I am still unable to use jspm to create dependencies which respect my preact aliases

from jspm-cli.

schlichtanders avatar schlichtanders commented on July 16, 2024

@guybedford any progress for aliasing a package to another subpackage?

from jspm-cli.

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.