summaryrefslogtreecommitdiff
path: root/cli/node
AgeCommit message (Collapse)Author
2023-04-21refactor(node): move most of cli/node to ext/node (#18797)David Sherret
This is just a straight refactor and I didn't do any cleanup in ext/node. After this PR we can start to clean it up and make things private that don't need to be public anymore.
2023-04-21refactor: move some CJS and ESM code analysis to ext/node (#18789)David Sherret
2023-04-17refactor(npm): add CliNodeResolver (#18742)David Sherret
2023-04-14refactor: break up `ProcState` (#18707)David Sherret
1. Breaks up functionality within `ProcState` into several other structs to break out the responsibilities (`ProcState` is only a data struct now). 2. Moves towards being able to inject dependencies more easily and have functionality only require what it needs. 3. Exposes `Arc<T>` around the "service structs" instead of it being embedded within them. The idea behind embedding them was to reduce the verbosity of needing to pass around `Arc<...>`, but I don't think it was exactly working and as we move more of these structs to be more injectable I don't think the extra verbosity will be a big deal.
2023-04-13refactor(cli,ext,ops): cleanup `regex` with `lazy-regex` (#17296)Yiyu Lin
- bump deps: the newest `lazy-regex` need newer `oncecell` and `regex` - reduce `unwrap` - remove dep `lazy_static` - make more regex cached --------- Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-04-06refactor(npm): use deno_npm and deno_semver (#18602)David Sherret
2023-03-30refactor(ext/node): add NodeEnv::Fs associated type (#18484)Bartek Iwańczuk
This commit adds associated type to "NodeEnv" trait, called "Fs". The "Fs" type has a trait bound on "NodeFs", which specifies APIs required for all ops and resolution APIs to function. A "RealFs" implementation of "NodeFs" is exported from the "deno_node" crate, that provides a default implementation for the trait. All code in "deno_node" extension was changed to use the "NodeFs" trait to handle file system operations, instead of relying on APIs from the standard library.
2023-03-27feat(core): initialize SQLite off-main-thread (#18401)Matt Mastracci
This gets SQLite off the flamegraph and reduces initialization time by somewhere between 0.2ms and 0.5ms. In addition, I took the opportunity to move all the cache management code to a single place and reduce duplication. While the PR has a net gain of lines, much of that is just being a bit more deliberate with how we're recovering from errors. The existing caches had various policies for dealing with cache corruption, so I've unified them and tried to isolate the decisions we make for recovery in a single place (see `open_connection` in `CacheDB`). The policy I chose was: 1. Retry twice to open on-disk caches 2. If that fails, try to delete the file and recreate it on-disk 3. If we fail to delete the file or re-create a new cache, use a fallback strategy that can be chosen per-cache: InMemory (temporary cache for the process run), BlackHole (ignore writes, return empty reads), or Error (fail on every operation). The caches all use the same general code now, and share the cache failure recovery policy. In addition, it cleans up a TODO in the `NodeAnalysisCache`.
2023-03-21feat: TypeScript 5.0.2 (except decorators) (#18294)David Sherret
This upgrades TypeScript to 5.0.2, but does not have ES decorator support because swc does not support that yet.
2023-03-20refactor(ext/node): untangle dependencies between js files (#18284)Bartek Iwańczuk
Moving some code around in `ext/node` is it's a bit better well defined and makes it possible for others to embed it. I expect to see no difference in startup perf with this change.
2023-03-09chore: update Rust to 1.68.0 (#18102)Bartek Iwańczuk
2023-02-24fix(npm): lazily install package.json dependencies only when necessary (#17931)David Sherret
This lazily does an "npm install" when any package name matches what's found in the package.json or when running a script from package.json with deno task. Part of #17916 Closes #17928
2023-02-22feat(task): support scripts in package.json (#17887)David Sherret
This is a super basic initial implementation. We don't create a `node_modules/.bin` folder at the moment and add it to the PATH like we should which is necessary to make command name resolution in the subprocess work properly (ex. you run a script that launches another script that then tries to launch an "npx command"... this won't work atm). Closes #17492
2023-02-22refactor: use deno_graph for npm specifiers (#17858)David Sherret
This changes npm specifiers to be handled by deno_graph and resolved to an npm package name and version when the specifier is encountered. It also slightly changes how npm specifier resolution occurs—previously it would collect all the npm specifiers and resolve them all at once, but now it resolves them on the fly as they are encountered in the module graph. https://github.com/denoland/deno_graph/pull/232 --------- Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-02-21fix(npm): improve peer dependency resolution (#17835)David Sherret
This PR fixes peer dependency resolution to only resolve peers based on the current graph traversal path. Previously, it would resolve a peers by looking at a graph node's ancestors, which is not correct because graph nodes are shared by different resolutions. It also stores more information about peer dependency resolution in the lockfile.
2023-02-15feat: wire up ext/node to the Node compatibility layer (#17785)Bartek Iwańczuk
This PR changes Node.js/npm compatibility layer to use polyfills for built-in Node.js embedded in the snapshot (that are coming from "ext/node" extension). As a result loading `std/node`, either from "https://deno.land/std@<latest>/" or from "DENO_NODE_COMPAT_URL" env variable were removed. All code that is imported via "npm:" specifiers now uses code embedded in the snapshot. Several fixes were applied to various modules in "ext/node" to make tests pass. --------- Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com> Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
2023-02-15refactor: use deno_graph's semver and npm structs (#17791)David Sherret
2023-02-10refactor: clean up "cli/node/mod.rs" and "ext/node" (#17713)Bartek Iwańczuk
This commit moves some code around from "cli/node/mod.rs" to "ext/node". Additionally "ext/node" was changed to factor out "ops.rs" and "polyfill.rs" modules.
2023-02-10refactor: allow to provide polyfills for Node modules from the snapshot (#17706)Bartek Iwańczuk
This commit does preparatory work to allow snapshotting Node.js compatibility layer, that currently lives in `std/node`. The logic was changed to allow loading some modules from the snapshot and some from the remote URL. Additionally "module_es_shim.js" that provides exports for "node:module" is now snapshotted.
2023-02-05 refactor: rename `deno` specifiers to `internal` (#17655)Leo Kettmeir
2023-01-27chore: upgrade to Rust 1.67 (#17548)David Sherret
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-01-24feat: support node built-in module imports (#17264)Bartek Iwańczuk
Co-authored-by: David Sherret <dsherret@gmail.com>
2023-01-10fix(npm): allow to read package.json if permissions are granted (#17209)Bartek Iwańczuk
This commit changes signature of "deno_core::ModuleLoader::resolve" to pass an enum indicating whether or not we're resolving a specifier for dynamic import. Additionally "CliModuleLoader" was changes to store both "parent permissions" (or "root permissions") as well as "dynamic permissions" that allow to check for permissions in top-level module load an dynamic imports. Then all code paths that have anything to do with Node/npm compat are now checking for permissions which are passed from module loader instance associated with given worker.
2023-01-05refactor(cli,core,ext,rt): remove some unnecessary `clone` or `malloc` (#17274)Yiyu Lin
2023-01-02chore: update copyright year to 2023 (#17247)David Sherret
Yearly tradition of creating extra noise in git.
2022-12-17chore: update to Rust 1.66.0 (#17078)linbingquan
2022-12-16fix(npm): fix require resolution if using --node-modules-dir (#17087)Bartek Iwańczuk
In our `require()` implementation we use a special logic to resolve "base path" when looking for matching packages, however this logic is in contradiction to what needs to happen if there's a local "node_modules" directory used. This commit changes require implementation to be aware if we're running off of global node modules cache or a local one.
2022-12-15fix(npm): improve exports resolution when type checking (#17071)David Sherret
Closes #17012
2022-12-05fix(npm): dependency types were sometimes not being resolved when package ↵David Sherret
had no types entry (#16958) Closes #16957
2022-11-30fix(npm): improve package.json exports support for types (#16880)David Sherret
2022-11-28fix(npm): don't resolve JS files when resolving types (#16854)David Sherret
Closes #16851
2022-11-28fix(npm): allow to inspect npm modules with --inspect-brk (#16841)Bartek Iwańczuk
2022-11-25fix(npm): better error message when attempting to use typescript in npm ↵David Sherret
packages (#16813)
2022-11-24fix(npm/check): prioritize exports over types entry (#16788)David Sherret
2022-11-21fix(npm): automatically find binary entrypoint when values are all the same ↵David Sherret
(#16735)
2022-11-21fix(npm): add suggestions to error message when can't find binary entrypoint ↵David Sherret
(#16733) Closes #16731
2022-11-16fix(npm): using types for packages with subpath (#16656)Bartek Iwańczuk
For CommonJS packages we were not trying different extensions for files specified as subpath of the package ([package_name]/[subpath]). This commit fixes that.
2022-11-16fix(npm): don't fail if conditional exports don't contains types (#16651)Bartek Iwańczuk
If resolving types for an npm package, we didn't find "types" entry in the conditional exports declaration we were falling-through to regular resolution, instead of short-circuiting and giving up on resolving types, which might lead to unwarranted errors. Closes https://github.com/denoland/deno/issues/16649
2022-11-15fix(npm): probing for files that have a file stem (#16641)Bartek Iwańczuk
2022-11-02fix(npm): add `console` global for node environment (#16519)David Sherret
This global is already isolated to node during type checking. Closes #16518
2022-10-21feat(unstable/npm): initial type checking of npm specifiers (#16332)David Sherret
2022-10-05fix(node): add dns/promises and stream/consumers (#16169)David Sherret
2022-10-01fix(npm): handle json files in require (#16125)Bartek Iwańczuk
2022-10-01perf: node cjs & esm analysis cache (#16097)David Sherret
This commit adds a cache for CJS and ESM analysis that is backed by an SQLite file. The connection to the DB is lazily created on first use, so shouldn't have impact on the startup time. Benched with running Vite Deno v1.26: ``` $ deno task dev Warning deno task is unstable and may drastically change in the future Task dev deno run -A --unstable --node-modules-dir npm:vite VITE v3.1.4 ready in 961 ms ➜ Local: http://localhost:5173/ ➜ Network: use --host to expose ``` This branch: ``` ../deno/target/release/deno task dev Warning deno task is unstable and may drastically change in the future Task dev deno run -A --unstable --node-modules-dir npm:vite VITE v3.1.4 ready in 330 ms ➜ Local: http://localhost:5173/ ➜ Network: use --host to expose ``` Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2022-09-28feat(npm): functionality to support child_process.fork (#15891)David Sherret
2022-09-22feat(npm): add flag for creating and resolving npm packages to a local ↵David Sherret
node_modules folder (#15971)
2022-09-14fix(npm): binary entrypoint for .js or no extension (#15900)Bartek Iwańczuk
2022-09-13refactor(npm): create general use `NpmPackageResolver` (#15882)David Sherret
2022-09-12fix(npm): use shim from deno_node crate for 'module' built-in module (#15881)Bartek Iwańczuk
2022-09-12fix(npm): support cjs resolution of package subpath with package.json (#15855)David Sherret