From be97170a193e8cecc5ce03ecd3c1d0add4a06bf7 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Wed, 25 Oct 2023 14:39:00 -0400 Subject: feat(unstable): ability to `npm install` then `deno run main.ts` (#20967) This PR adds a new unstable "bring your own node_modules" (BYONM) functionality currently behind a `--unstable-byonm` flag (`"unstable": ["byonm"]` in a deno.json). This enables users to run a separate install command (ex. `npm install`, `pnpm install`) then run `deno run main.ts` and Deno will respect the layout of the node_modules directory as setup by the separate install command. It also works with npm/yarn/pnpm workspaces. For this PR, the behaviour is opted into by specifying `--unstable-byonm`/`"unstable": ["byonm"]`, but in the future we may make this the default behaviour as outlined in https://github.com/denoland/deno/issues/18967#issuecomment-1761248941 This is an extremely rough initial implementation. Errors are terrible in this and the LSP requires frequent restarts. Improvements will be done in follow up PRs. --- cli/lsp/analysis.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cli/lsp/analysis.rs') diff --git a/cli/lsp/analysis.rs b/cli/lsp/analysis.rs index 6515e7dc0..f8ace060a 100644 --- a/cli/lsp/analysis.rs +++ b/cli/lsp/analysis.rs @@ -253,7 +253,7 @@ impl<'a> TsResponseImportMapper<'a> { let root_folder = self .npm_resolver .as_ref() - .and_then(|r| r.resolve_pkg_folder_from_specifier(specifier).ok()) + .and_then(|r| r.resolve_package_folder_from_path(specifier).ok()) .flatten()?; let package_json_path = root_folder.join("package.json"); let package_json_text = std::fs::read_to_string(&package_json_path).ok()?; -- cgit v1.2.3