module: allow running .ts in node_modules if private#55385
module: allow running .ts in node_modules if private#55385marco-ippolito wants to merge 2 commits into
Conversation
|
Review requested:
|
|
This solution works for me. |
|
|
||
| Type stripping is not supported for files descendent of a `node_modules` directory. | ||
| Type stripping is not supported for files descendent of a `node_modules` directory, | ||
| where package.json is missing or does not contain the property `"private": true`. |
There was a problem hiding this comment.
| where package.json is missing or does not contain the property `"private": true`. | |
| where package.json is missing or does not contain the property `"private": true`. |
Is there any chance it can be missing?
| function isPrivateNodeModule(filename) { | ||
| const packageJsonReader = require('internal/modules/package_json_reader'); | ||
| const resolved = StringPrototypeStartsWith(filename, 'file://') ? filename : pathToFileURL(filename).href; | ||
| const packageConfig = packageJsonReader.getPackageScopeConfig(resolved); |
There was a problem hiding this comment.
should we cache already analized paths?
Like everything under node_modules/foo once we have already read read node_modules/foo/package.json
|
I said this on nodejs/typescript#14 (comment), but I don't understand the use case here; if you have a package like this, you can't have published it because it's marked private. How did you get the package, then? For monorepos, I would really expect that you'd get it via a symlink, in which case the |
Probably easier to use since it doesnt require additional tooling. |
|
That doesn't really answer my question... I understand that using this flag prevents needing another tool like |
|
I thought that |
|
@marco-ippolito were you thinking about bundledDependencies? |
|
@marco-ippolito is this possible now? I am using |
Nope there is no consensus on landing this |
Refs: nodejs/typescript#14
This PR checks when attempting to run
.tsfiles undernode_modulesif the package.json contains the propertyprivate: true.This should make possible to use strip-types in monorepos, without allowing package maintainer to publish their packages on npm without compiling first.
Also not very performant since is checking/parsing the package.json every time a file under node_modules is encountered, it requires some sort of caching