module: add --experimental-strip-private-modules #63869
Conversation
|
Review requested:
|
003fda2 to
88c3881
Compare
aduh95
left a comment
There was a problem hiding this comment.
We'd need to document private in https://nodejs.org/api/packages.html#nodejs-packagejson-field-definitions
88c3881 to
5c48075
Compare
|
Adding the |
aduh95
left a comment
There was a problem hiding this comment.
I don't think it's worth it, also I don't think that we can use private to reliably guess if a package was downloaded from a registry or not, and it adds arguably a lot of complexity (in comparison for e.g. adding a loader, or not putting the code inside node_modules)
|
Weighing in from the TypeScript team: We're OK with this, and don't have any concerns about this eventually going unflagged either. That said, we wanted to re-emphasize @ljharb's and others' comments in the prior PR thread. Our top priority in this space remains ensuring that un-compiled .ts is never the entry point for a package in the public registry. The fundamental technical motivations behind that haven't changed, and we don't see any path forward where they could change. Keeping this restricted to |
9f68ed3 to
2cfa6d1
Compare
To be explicit for @nodejs/typescript: this is not a stepping stone to public-registry TS. @aduh95 I kindly ask you to reconsider. |
Signed-off-by: Marco Ippolito <marcoippolito54@gmail.com>
2cfa6d1 to
76740fc
Compare
andrewbranch
left a comment
There was a problem hiding this comment.
It would also be good to have one of the test fixtures' "private": true packages include a relative import of another TypeScript file in the same package, so it's clear that finding the "private": true package.json that allows type stripping doesn't depend on that same package.json being looked up as part of module resolution. I think the implementation already works this way, but it wasn't clear from reading the tests.
Just to be clear: I don't think Node has any technical issues with TypeScript packages in And if I remember correctly, the performance problem had to do with tsc parsing all the types of those packages, and their potential publishing with different tsconfig settings. And if they're published to the public registry as plain JavaScript, they're parsed as such and so no problem. Correct so far? So wouldn't then a potential solution to the tsc performance problem be for tsc to treat TypeScript packages under |
|
Sorry, I don't understand that suggestion and how it would address any of the concerns we've raised every time this discussion comes up. |
|
I don't think it's really about performance at all; it's that it would effectively prevent the TS team from ever evolving the language in a breaking way without breaking users. |
TS generally doesn't read the JS source of npm packages at all. I think you're confused about two entirely different processes. Where do types for the package come from in this proposal? |
The same place they would today when people publish JavaScript, in .d.ts files. From the last time a TypeScript team member explained the concern:
So just don't. When people complain that they shouldn't need to punish .d.ts files since they're publishing TypeScript source, just refuse to infer the types of packages without .d.ts files and explain why. The performance problem simply doesn't need to happen. In other words, tsc doesn't change at all, and the performance problem you fear just doesn't happen. People still need to punish .d.ts files as they do today, and they have the option of publishing either JavaScript or TypeScript sources alongside. |
Followup of #63853
Adds a flag to allow type stripping inside
node_modulesONLY if private.I think I covered #63853 (comment) concerns about smuggling private package.json's in a non private package