Git Product home page Git Product logo

Comments (8)

bryanforbes avatar bryanforbes commented on July 28, 2024

Currently, @dojo/shim is a peer dependency of @dojo/core (it must be installed as a sibling of @dojo/core) and tslib is a dependency of @dojo/shim. I just spoke with @matt-gadd and @agubler and we should probably re-evaluate what should be a peerDependency vs. a dependency vs. devDependency.

from core.

mgroenhoff avatar mgroenhoff commented on July 28, 2024

You can not assume that because tslib is a dependency of @dojo/shim that is installed next to @dojo/core, that tslib will also be accessible to @dojo/core.

Technically tslib must be a dependency of @dojo/core (because it is). You can just let NPM figure out how it dedupes and optimalizes the final output tree.

For example it is perfectly fine to have this dependency tree (which i have):

node_modules
- @dojo
    - core
       - node_modules
          -<currently tslib is missing here>
    - shim
       - node_modules
          -tslib

Using regular NPM this will probably all be flattened as much as possible and it indeed will place tslib in the root node_modules folder therefore being visible to @dojo/core because of it searching up the tree.

Peer dependencies are mostly used for regular dependencies while letting the user determine which version is used.

from core.

bryanforbes avatar bryanforbes commented on July 28, 2024

Technically tslib must be a dependency of @dojo/core

It should be a peer dependency of @dojo/shim, which then leads it to be a peer dependency of @dojo/core.

Using regular NPM

Which version?

Peer dependencies are mostly used for regular dependencies but you want the user to choose which version he uses.

We actually don't want the user choosing which version he uses. We can assure that @dojo/* works with the version of tslib specified in the dependency of @dojo/shim. As long as it's within the 1.8.x series, the patch version doesn't matter. But @dojo/shim will not work with [email protected]. This is why tslib should be a peer dependency: so every @dojo/* package (and the user's code) will use the same tslib and then the user can't mess that up.

from core.

mgroenhoff avatar mgroenhoff commented on July 28, 2024

I thought you were talking about @dojo/core being a peer dependency of @dojo/shim. Peer dependencies also have constraints just as regular dependencies do.

It should be a peer dependency of @dojo/shim, which then leads it to be a peer dependency of @dojo/core.

You can not make assumptions like this just because you do not know where "a package manager" places them.

Consider this scenario: I am developing a package that depends on [email protected] (one that does not work with @dojo/shim).
If i use NPM to install to install the following dependencies:
npm i [email protected] @dojo/core @dojo/has @dojo/shim

  "dependencies": {
    "@dojo/core": "^0.2.1",
    "@dojo/has": "^0.1.1",
    "@dojo/shim": "^0.2.3",
    "tslib": "^1.6.1"
  }

Them npm installs it as follows:

@dojo/core will use [email protected]

from core.

mgroenhoff avatar mgroenhoff commented on July 28, 2024

Why is this labeled question. This is definitely a bug!
Let me try to make it easier to understand. Please create a new directory and run the following:

$ npm i @dojo/core @dojo/has @dojo/shim --no-package-lock --global-style

$ node -e "require('@dojo/core/async/Task')"

Error: Cannot find module 'tslib'
    at Function.Module._resolveFilename (module.js:527:15)
    at Function.Module._load (module.js:476:23)
    at Module.require (module.js:568:17)
    at require (internal/module.js:11:18)
    at \node_modules\@dojo\core\async\Task.js:12:19
    at Object.defineProperty.value (\node_modules\@dojo\core\async\Task.js:3:17)
    at Object.<anonymous> (\node_modules\@dojo\core\async\Task.js:9:3)
    at Module._compile (module.js:624:30)
    at Object.Module._extensions..js (module.js:635:10)
    at Module.load (module.js:545:32)

The source code of @dojo/core contain require('tslib') statements so how could tslib not be a dependency of @dojo/core?

from core.

mgroenhoff avatar mgroenhoff commented on July 28, 2024

Do i need to make a pull request for this?

from core.

agubler avatar agubler commented on July 28, 2024

@mgroenhoff Hi, sorry for the delay getting back to you! We'd be very happy to take a pull request to make tslib a dependency of dojo/core

from core.

mgroenhoff avatar mgroenhoff commented on July 28, 2024

For reference: dojo/meta#226

from core.

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.