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

require doesn't resolve in the global cache dir if referrer is not in DENODIR #25189

Open
nathanwhit opened this issue Aug 23, 2024 · 0 comments
Labels
bug Something isn't working correctly node compat

Comments

@nathanwhit
Copy link
Member

nathanwhit commented Aug 23, 2024

The scenario is roughly as follows:

You're using the global resolver (no node_modules dir) and you have a config file

// playwright.config.js (located in your project dir)
import playwrightTest from "playwright/test"; // in import map (there is no package.json)

Playwright (which is in the global cache dir) adds a hook that gets called right before the builtin require, then requires your config file (require(userConfigFilePath)).

Playwright's require hook transpiles your config file to CJS, which results in

// transpiled playwright.config.js ("located" in user's project dir)
const playwrightTest = require("playwright/test");

then calls deno's actual require function.

When deno hits require("playwright/test"); it searches relative to the config file (but no matches), then searches in "/node_modules", "/../node_modules" (etc.) but there are no matches, because the dependency is actually in the global cache dir.

Ideally we could handle this by resolving in the global cache dir instead of in the node_modules dirs (which don't exist or apply).


Seen in #16899 (comment) (repro at https://github.com/jollytoad/ahx/tree/df1b391bb5adb51e879da17612570f7e7dd025f7)

@nathanwhit nathanwhit added bug Something isn't working correctly node compat labels Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly node compat
Projects
None yet
Development

No branches or pull requests

1 participant