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

glob implementation should not ignore node_modules #2151

Closed
boneskull opened this issue Jan 27, 2023 · 2 comments · Fixed by #2164
Closed

glob implementation should not ignore node_modules #2151

boneskull opened this issue Jan 27, 2023 · 2 comments · Fixed by #2164
Labels
bug Functionality does not match expectation

Comments

@boneskull
Copy link
Contributor

Search terms

node_modules glob

Expected Behavior

I expected to be able to use an entry point located within a node_modules folder using the packages strategy, as suggested in this comment by @Gerrit0.

Actual Behavior

If TypeDoc's glob implementation encounters a node_modules dir anywhere within a path, it is explicitly ignored.

Steps to reproduce the bug

  1. Create a typedoc.json with an entry point in node_modules
  2. Run typedoc
  3. Failure: no entry points found

Alternatively:

  1. Create a typedoc.json with an entry point in node_modules and another (known good entry point) not in a node_modules
  2. Run typedoc
  3. Notice that the entry point in node_modules is excluded from the build

Environment

  • Typedoc version: v0.23.24
  • TypeScript version: v4.7.4 / v4.9.4
  • Node.js version: v18.x
  • OS: macOS

A potential fix is to remove the explicit check for node_modules from the glob implementation. As it's unclear to me why it's present, this may have unintended consequences. Removing it does not fail the test suite. Another route would be to support an ignoreNodeModules option for glob -- defaulting to true -- and be set to false when computing entry points.

My workaround right now is a monkeypatch which bypasses Node's subpath exports restrictions:

import {sync as glob} from 'glob';

require(path.join(
    somePackageRoot,
    'node_modules',
    'typedoc',
    'dist',
    'lib',
    'utils',
    'fs.js'
)).glob = glob;
@boneskull boneskull added the bug Functionality does not match expectation label Jan 27, 2023
@boneskull
Copy link
Contributor Author

(would send PR if this is a real bug; it seems like @Gerrit0 thinks it should work, unless I'm misunderstanding)

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Feb 1, 2023

As it's unclear to me why it's present

If I recall correctly, because people were specifying inputs like **/*.ts, which required traversing >100k files in node_modules, and they didn't actually mean to include that. On a slow disk, this was making the build take far longer than it should. I'd have to go back in history quite a while to find it, was at least a couple years ago.

If there's a smart way to ignore node_modules unless explicitly listed in the path, I think that'd be ideal... but it's probably okay to get rid of that exclude.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Functionality does not match expectation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants