-
Notifications
You must be signed in to change notification settings - Fork 261
Use NPM as the registry #223
Comments
IMO I don't see too much of a benefit out of it, unless your plan is to retire This solution would make the coupling between the source and distribution channel even more, and the syntax/structure could be inconsistent for different distribution channels. For example, if I use some libraries directly by downloading them, or purely rely on CDN, I don't need a local One concrete example would be ExtJS. Its commercial version is not open sourced and not available through any distribution channel. I have to download it and reference it locally. In that case In order to support this scenario, By the way, does |
My initial thought was "yay brilliant idea". Having read your pros and con's I'm not so sure.
This is a massive problem. My gut feeling is that the future for TypeScript is a Registry and non-ambient type definitions. The reality is there are many projects reliant on DT and they're unlikely to take the leap to Typings if DT becomes closed to them. Separate to that, it seems that usage of Typings may become more complicated as a result. I've only just had my first cup of coffee but I didn't really follow the usage of Typings in speculative npm-land. Looks non-intuitive to my tired eyes.
Also a big loss. How would that affect users who have to stick with Angular 1.2.x for instance? That's not me but there will be many in that boat. (And similar) |
Here is my counter proposal: https://goo.gl/fWsqax that doesn't suffer from many of your cons. I discussed this design with @mhegazy in December 2015 and both of us agreed that it was doable but needed to be fleshed out and implemented. |
We should set up another call to discuss a way forward here. We've been looking at changes we can make in the language and toolset to ease this problem (e.g. see microsoft/TypeScript#7125 ), and have some ideas along this line. Are you folks free some time next week (perhaps Mon or Tue)? |
@billti Sounds good. I have seen those and excited for those changes. I'm available either of those days, but feel free to follow up offline. @IgorMinar Actually, I've read your proposal and it actually looks practically identical but more limiting. Should I leave comments on the difference here? It's possible I just wasn't very clear last night creating this issue and something is lost in translation. |
@IgorMinar I'm of the opinion that a half-way approach might be interesting and work, where I implement the ability to use imports from From your proposal, the main differences I see is:
Most likely we'll just need to do some grunt work here to upgrade to both latest TypeScript version (with global augmentation) and make them non-ambient (90% of the time minimal effort).
Sorry, by multiple versions I should have said multiple distributions. There'd be |
@blakeembrey repackaging npm packages under
|
No, you don't repackage everything. You re-export it. I believe this is in my first example. main.js module.exports = require('express') main.d.ts function express (): any;
declare namespace express {}
export = express package.json {
"name": "@typings/express",
"dependencies": {
"express": "<semver version from `typings.json`>"
}
} Some of the other pieces are valid, but they are essentially the same issues we'll run into anyway. In this case, dependencies are always typed. If the definition in NPM is already typed, it doesn't need to exist under |
@blakeembrey I see, I missed the reexport piece. I still think that you are proposing to fork the npm ecosystem in this way and this is going to be really troublesome. 3rd party typings is an orthogonal issue to the js delivery and by conflating the two we'll see ripple effects through the whole package and tools ecosystem. npm gave us name registry for the js world, we should cherish it. I believe that your proposal to fork the registry is going to have severe side-effects and that's not acceptable. Imagine flow would do the same and now we'd have I think the 3rd party typings delivery must be significantly improved but not at the cost of breaking the non-ts world especially since it can be avoided. |
Doesn't having peer dependencies or real dependencies on type definitions create this same dependency path issue? It's just pushed out of the critical path. Is your suggestion more around just using the registry or is it also using the NPM tooling? From the proposal I gathered you wanted to be able to use the tooling too and drop using For one, you could do:
|
no. while your proposal forces users to import Now the question is how to get |
@IgorMinar Just noticed you are not on the Slack channel, so I'm including the link here to the Gist for ideas Ryan and I have been discussing. It shares a lot in common with your doc, and hopefully covers some of the above: https://gist.github.com/RyanCavanaugh/2ebc036361e53f8d6f69 At this point, our thinking is that we should be rolling some of the basic type acquisition mechanisms into TypeScript itself. There's a few reasons for this:
Give it a read, comment, and then lets all try and converge next week. Everyone on this thread is a key stakeholder in landing a great solution here, and it seems we're all thinking along the same lines - so I'm optimistic that we're close! |
Yeah, that looks very similar to my proposal, except that what you call I think Blake has a major concern about the mono-repo approach and we On Sat, Feb 20, 2016 at 2:30 AM Bill Ticehurst notifications@github.com
|
Are you advocating the actual From http://blog.npmjs.org/post/110924823920/npm-weekly-5
If I'm misunderstanding your usage of |
@billti yes, those peerDependencies. not installing by default is the correct behavior. what's not correct is that there is a lot of hand-holding involved in dealing with peerDeps in the current npm. I'll be looking into fixing this via a PR to npm next week. |
I'd be interested in what you had in mind here. I just tried re-reading the doc, but still can't grasp what you are using In ideas we've been tossing around, you wouldn't have to install each The structure and versioning of the types repository is something to be careful with. If we try and maintain a matrix of libraries x versions x TS compiler releases, it will become unwieldy quickly. We need to balance being useful and also maintainable. In reality the vast majority of updates to type definitions are for the latest version of the package with the latest version of the compiler. Definitely a key problem though for a workable & well supported ecosystem. |
peerDependencies tell you if you have a version mismatch between the This mismatch could happen if you update one of your packages but forget to Using peerDependencies a typings package expresses what version of the
|
Also keep in mind that the peerDependencies in my proposal are not meant to I don't think that setting up dependencies between typings packages as It is sufficient for installer to fetch typings for direct package The only exception to this is reexported transitive dependencies. e.g. how
|
I'm sure this'll come up in our call, but using Re-exported type dependencies are also quite common, but more common with option interfaces than actual implementation I've found. Just to clear it up, you suggest using all of the dependency fields in |
I'm trying to understand the big picture here. ObjectiveZero or near zero configuration for user to get the benefit of typings in javascript or typescript environment (through Problems to solve
Package DiscoveryEnvironment variations: npm, bower, jspm, NuGet, "no package manager", etc. Typings DeliveryDiscussion in this thread focus on using npm as the distribution channel for typings. If these are true, I would suggest to separate Package Discovery and Typings Delivery. We need multiple Package Discovery strategies to support different environments, but we only need one Typings Delivery mechanism, whether it is npm or http (typings/registry). My two cents. |
@blakeembrey I think you misunderstand my proposed use of peerDependencies. I'm proposing that for a package Hopefully this scenario will illustrate the value:
We might need to make some tweaks in npm (via a PR) to ensure that the Now if we were to use the typings installer as a postInstall hook then the workflow would look like this:
I much more prefer this, but it requires the typings installer to be created and npm needs to be tweaked to call the postInstall hook after |
Thanks @IgorMinar . That clarifies things a lot. I do still worry about using I would expect something like a |
For this particular usage the peerDeps work the same in npm v2 and v3. If you want to do the compatible check in tsc you will still need a place
|
@IgorMinar Thanks for the clarification. That makes a lot more sense now. Looking forward to our discussion later this week now so we can formulate a plan. |
IMHO this is the best approach. I would be really happy if this goes through and it's documented better. Having another package manager ( as tsd, typings ) doesn't give the scalable infrastructure npm built. I even suggested this in DefinitelyTyped/DefinitelyTyped#2150 (comment)
npm supports a tag name, so a website with a npm query that filters repos with the tag name ( similar to http://yeoman.io/generators/ ) will be sufficient. |
@drinchev I agree. I've talked with the TypeScript team and they have plans for using NPM for aliases of top-level module names. Once they have the infrastructure set up for that to work in the compiler, I can know how I can also use it because Typings is more than just top-level aliases - it has type definitions for multiple different sources and ambient definitions (E.g. Atom, Electron, etc). Those don't fit into that model so well, but if I can also use it then great 👍 So, once TypeScript merges their library feature I'll be testing it and if it works over sub-dependencies with multiple namespaces (not just with |
@drinchev So the biggest thing here is that I don't think any of this can be built or bought into until the TypeScript library feature exists to enable some of it. The issue with switching to NPM as the registry to serve definitions is one thing, but actually consuming those is another. There needs to be the ability to create aliases that can be discovered properly used by the compiler to enable real external module support. Without that, Typings still has to do it's hacky chore of creating a bundle with namespacing, etc. |
Thanks for the clarification. I read more deeply this issue and it looks like TypeScript's team will help. However as far as I followed the conversation, I saw that the only reason for not letting
No offense, but I honestly think, with the current state of npm and the micro-modules explosion ( Having typed-wrappers for the npm modules, hosted on npm actually requires almost no technical effort. People already started doing that ( https://www.npmjs.com/~weswigham ) and I also created my own PoC ( https://github.com/drinchev/ts-experiment ). It works with no TypeScript modifications. I'm not sure what the final solution of TypeScript team will be, but having another package tool seems unneeded if the community agrees to use npm prefixed modules. I'm really sorry if I've missed something that makes my arguments flawed. |
Can we close this now? |
Sure, sounds good. Typings will live as is since I don't have the development time to transition it and the effort should instead be put against the native TypeScript implementation. |
Little background: https://twitter.com/IgorMinar/status/700452928197275648
This is a proposal I have dismissed in the past because of a number of flaws, but I've spent a lot more time thinking about it more critically this time. I'm opening this in hope of having a discussion and discovering possible flaws or enhancements for using a different approach with Typings. I realise some features will go away in this implementation, but if the cons outweigh the pros it's a likely implementation I'll attempt for 1.0.
The proposal: Use NPM as the registry and kill feature duplication of Typings.
Summary:
@typings
namespace on NPM to publish type definitions of NPM packagestypings.json
file - when a type definition is added to the registry, we create an NPM package with the version and publish to NPM (E.g.express
will be republished as@typings/express
)express/<path>
).d.ts
files and generate.js
files that justmodule.exports = require('express/<path>')
require('express')
torequire('@typings/express')
typings
CLI will likely still exist, but it'll be a thin layer over the top of existing registries mapping commandstypings install express --save
maps tonpm install @typings/express@latest --save --save-exact
typings.json
file used by the Typings registry repo would useversion
as a semver range, and that would map to{ "dependencies": "<name>": "<version>" }
when generating thepackage.json
Issues/Questions:
node
either becomes@ambient-typings/node
or@typings/ambient-node
(which means option two affects regular imports to avoid possible real/ambient name collisions)typings package
command that'll do the same thing as building for NPMPros:
typings-<bower-dep>
, however not all registries have dedicated namespaces which is a conCons:
4.6.2-6
Afterthought: It's also possible to implement a similar system without the actual NPM registry in use, where things become a hybrid solution.
typings install express
installs from the registry repo (instead of NPM) but sets upnode_modules/@typings/express
for you. This would work better with other package managers and maintain consistency. Typed dependencies can be keyed inpackage.json
. Pros/cons?The text was updated successfully, but these errors were encountered: