Skip to content
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

From debian : please support multiple system dir #33661

Open
bastien-roucaries opened this issue Sep 29, 2019 · 9 comments
Open

From debian : please support multiple system dir #33661

bastien-roucaries opened this issue Sep 29, 2019 · 9 comments
Labels
Needs Proposal This issue needs a plan that clarifies the finer details of how it could be implemented. Suggestion An idea for TypeScript

Comments

@bastien-roucaries
Copy link

Under debian and other distrib we want to load systemdir from a search path.

for instance we want first to look up from lib/x86_64-linux-gnu/nodejs then share/nodejs then lib/nodejs'

I tried a local patch but I do not suceed.

Could you help us ?

rouca@debian.org

@bastien-roucaries
Copy link
Author

Patches incomplete from my side :

Index: node-typescript/lib/tsc.js
===================================================================
--- node-typescript.orig/lib/tsc.js
+++ node-typescript/lib/tsc.js
@@ -75146,14 +75146,20 @@ var ts;
                 }
             }
             if (rootNames.length && !skipDefaultLib) {
-                var defaultLibraryFileName = getDefaultLibraryFileName();
+               var defaultLibraryFileName = getDefaultLibraryFileName();
+               var relativePaths = process.config.variables.node_relative_path;
+               var relativePathsSplitted = relativePaths.split(':');
                 if (!options.lib && defaultLibraryFileName) {
-                    processRootFile(defaultLibraryFileName, true, false);
+                   ts.forEach(relativePathsSplitted, function(systempath) {
+                       processRootFile(systempath, true, false);
+                   });
                 }
                 else {
-                    ts.forEach(options.lib, function (libFileName) {
-                        processRootFile(ts.combinePaths(defaultLibraryPath, libFileName), true, false);
-                    });
+                   ts.forEach(relativePathsSplitted,function(systempath) {
+                       ts.forEach(options.lib, function (libFileName) {
+                            processRootFile(ts.combinePaths(systempath, libFileName), true, false);
+                       });
+                   });
                 }
             }
             missingFilePaths = ts.arrayFrom(ts.mapDefinedIterator(filesByName.entries(), function (_a) {

@bastien-roucaries
Copy link
Author

The best for us will be the possibility to override hard coded system path by using a environement variable with path separated with : like TYPESCRIPT_PATH="/usr/share/nodejs/@types:/usr/lib/nodejs/@types:/usr/local/share/nodejs/@types"

@pravi
Copy link

pravi commented Oct 3, 2019

I think if tsc searches in NODE_PATH or default paths set in nodejs instead of just node_modules for finding types, that will be the best option.

@pravi
Copy link

pravi commented Oct 3, 2019

node -e "console.log(process.config.variables.node_relative_path);"
lib/x86_64-linux-gnu/nodejs:share/nodejs:lib/nodejs

So nodejs in debian looks in these paths for finding modules (configured with https://salsa.debian.org/js-team/nodejs/blob/master/debian/patches/dfhs_module_path_arch_triplet.patch), but tyepescript does not check in these paths when looking for type definitions.

@pravi
Copy link

pravi commented Oct 3, 2019

tsc does not recognize NODE_PATH environment variable as well.

@sandersn sandersn added Needs Proposal This issue needs a plan that clarifies the finer details of how it could be implemented. Suggestion An idea for TypeScript labels Oct 25, 2019
@SnarkBoojum
Copy link

Well, the proposal is that tsc should have a list of directories where it would look for modules and/or definitions. The package providing tsc would then be lightly patched in order to add Debian's system directories to that list. That would avoid stupid patches to tsconfig.json like this one in many packages.

@guimard
Copy link

guimard commented Dec 4, 2020

Hi, any news here ?

@weswigham
Copy link
Member

There's a typeRoots compiler option that probably does what you want.

@guimard
Copy link

guimard commented Dec 5, 2020

Hi @weswigham, no it is not. Typescript does not follow node.js resolution policy, even when moduleResolution is set to node. So tsc isn't able to find a globally installed module

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Proposal This issue needs a plan that clarifies the finer details of how it could be implemented. Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

6 participants