deno
f542a810 - fix: support npm: specifiers in --preload and --import (#34346)

Commit
81 days ago
fix: support npm: specifiers in --preload and --import (#34346) `deno run --preload npm:foo` and `deno run --import npm:foo` previously failed with `Could not find constraint 'foo' in the list of packages`, because the npm package referenced by the preload/import flag was never installed before the preload module list was resolved. Bare specifiers that mapped to an npm package via an import map or `package.json` dependency were also unresolved, since the preload pipeline did not run them through the workspace resolver. This change threads the `WorkspaceMainModuleResolver` into `preload_modules_with_resolver` so bare specifiers in `--import` / `--preload` resolve the same way as the main module. It also moves npm package collection inside `CliMainWorkerFactory::create_custom_worker` to gather requirements from the main module, preload list, and require list together, and installs them in one batch before resolution proceeds. Spec test coverage is added in `tests/specs/run/preload_modules_npm` exercising both `--import npm:` and `--preload npm:`. Fixes #34303
Author
Parents
Loading