-
Notifications
You must be signed in to change notification settings - Fork 30.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
module: allow running .ts in node_modules if private #55385
module: allow running .ts in node_modules if private #55385
Conversation
Review requested:
|
This solution works for me. |
@@ -3041,7 +3041,8 @@ import 'package-name'; // supported | |||
added: v22.6.0 | |||
--> | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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? |
Refs: nodejs/typescript#14
This PR checks when attempting to run
.ts
files undernode_modules
if 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