summaryrefslogtreecommitdiff
path: root/cli/module_loader.rs
AgeCommit message (Collapse)Author
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): add `Emitter` struct (#18690)David Sherret
Removes the functions in the `emit` module and replaces them with an `Emitter` struct that can have "ctor dependencies" injected rather than using functions to pass along the dependencies. This is part of a long term refactor to move more functionality out of proc state.
2023-04-04refactor(core): Improve ergonomics of managing ASCII strings (#18498)Matt Mastracci
This is a follow-on to the earlier work in reducing string copies, mainly focused on ensuring that ASCII strings are easy to provide to the JS runtime. While we are replacing a 16-byte reference in a number of places with a 24-byte structure (measured via `std::mem::size_of`), the reduction in copies wins out over the additional size of the arguments passed into functions. Benchmarking shows approximately the same if not slightly less wallclock time/instructions retired, but I believe this continues to open up further refactoring opportunities.
2023-03-21perf(core) Reduce script name and script code copies (#18298)Matt Mastracci
Reduce the number of copies and allocations of script code by carrying around ownership/reference information from creation time. As an advantage, this allows us to maintain the identity of `&'static str`-based scripts and use v8's external 1-byte strings (to avoid incorrectly passing non-ASCII strings, debug `assert!`s gate all string reference paths). Benchmark results: Perf improvements -- ~0.1 - 0.2ms faster, but should reduce garbage w/external strings and reduces data copies overall. May also unlock some more interesting optimizations in the future. This requires adding some generics to functions, but manual monomorphization has been applied (outer/inner function) to avoid code bloat.
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-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-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-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-09refactor: deno_graph 0.43 upgrade (#17692)David Sherret
2023-02-03refactor: remove old cjs_esm_translations in graph_util (#17643)David Sherret
This isn't used.
2023-02-03refactor: reland "preserve ProcState::file_fetcher between restarts" (#17636)Nayeem Rahman
Just some watcher init step that I thought would be "cloned over" but needs to be done again on reset.
2023-01-30Revert "fix(watch): preserve `ProcState::file_fetcher` between restarts ↵Bartek Iwańczuk
(#15466) (#17591) This reverts commit 3545bff678f20c3fdf17fe6b26f96cf1b74f917c.
2023-01-27chore: upgrade to Rust 1.67 (#17548)David Sherret
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-01-10fix(watch): preserve `ProcState::file_fetcher` between restarts (#15466)Nayeem Rahman
This commit changes "ProcState" to store "file_fetcher" field in an "Arc", allowing it to be preserved between restarts and thus keeping the state alive between the restarts. File watchers for "deno test" and "deno bench" now reset "ProcState" between restarts.
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-07refactor(permissions): add PermissionsContainer struct for internal ↵Bartek Iwańczuk
mutability (#17134) Turns out we were cloning permissions which after prompting were discarded, so the state of permissions was never preserved. To handle that we need to store all permissions behind "Arc<Mutex<>>" (because there are situations where we need to send them to other thread). Testing and benching code still uses "Permissions" in most places - it's undesirable to share the same permission set between various test/bench files - otherwise granting or revoking permissions in one file would influence behavior of other test files.
2023-01-02chore: update copyright year to 2023 (#17247)David Sherret
Yearly tradition of creating extra noise in git.
2022-11-28refactor: create util folder, move nap_sym to napi/sym, move http_cache to ↵David Sherret
cache folder (#16857)
2022-11-25refactor: move dts files, diagnostics.rs, and tsc.rs to tsc folder (#16820)David Sherret
2022-11-18chore: use Rust 1.65.0 (#16688)Aaron O'Mullan
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-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): align Deno importing Node cjs with Node esm importing cjs (#15879)David Sherret
2022-09-10fix(npm): align Node esm code importing cjs with Node (#15838)David Sherret
2022-09-03fix(npm): add more context to errors when file doesn't exist (#15749)Bartek Iwańczuk
2022-08-24fix(unstable): various resolution bugs for npm: specifiers (#15546)Bartek Iwańczuk
Co-authored-by: David Sherret <dsherret@gmail.com>
2022-08-22perf: cache swc dependency analysis and don't hold onto `ParsedSource`s in ↵David Sherret
memory (#15502)
2022-08-20feat(unstable): initial support for npm specifiers (#15484)David Sherret
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2022-07-19feat: emit files on demand and fix racy emit (#15220)David Sherret
2022-06-29refactor: rename `RootConfig` to `CliOptions` (#15007)David Sherret
2022-06-28refactor: add `RootConfig` (#14985)David Sherret
2022-03-23chore: remove all `pub(crate)`s from the cli crate (#14083)David Sherret
2022-03-11fix(compat): cjs/esm interop for dynamic imports (#13792)Bartek Iwańczuk
This commit fixes CJS/ESM interop in compat mode for dynamically imported modules. "ProcState::prepare_module_load" was changed to accept a list of "graph roots" without associated "module kind". That module kind was always hardcoded to "ESM" which is not true for CJS/ESM interop - a CommonJs module might be imported using "import()" function. In such case the root of the graph should have "CommonJs" module kind instead of "ESM".
2022-02-01refactor: integrate deno_graph breaking changes (#13495)Kitson Kelly
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2022-01-07chore: update copyright to 2022 (#13306)Ryan Dahl
Co-authored-by: Erfan Safari <erfanshield@outlook.com>
2021-12-21refactor: Cleanup core/modules.rs (#13149)Bartek Iwańczuk
2021-11-16fix(cli): short-circuit in prepare_module_load() (#12604)Nayeem Rahman
2021-10-11refactor: integrate deno_graph into CLI (#12369)Kitson Kelly
2021-09-24refactor: Remove op_state parameter (#12202)Ryan Dahl
2021-09-24refactor: Rename ProgramState to ProcState (#12204)Ryan Dahl
Move Arc into struct
2021-09-11refactor: use import_map crate (#11974)Bartek Iwańczuk
Removes ImportMap implementation from "cli/" and instead uses "import_map" crate
2021-05-31fix(cli): Don't statically error on dynamic unmapped bare specifiers (#10618)Nayeem Rahman
Fixes #10168 Fixes #10615 Fixes #10616
2021-05-17fix: static import permissions in dynamic importsLuca Casonato
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2021-02-17Make ModuleSpecifier a type alias, not wrapper struct (#9531)Ryan Dahl
2021-01-11chore: update copyright to 2021 (#9092)Yusuke Tanaka
2021-01-06feat: Add configurable permissions for Workers (#8215)Steven Guerrero
This commit adds new option to "Worker" Web API that allows to configure permissions. New "Worker.deno.permissions" option can be used to define limited permissions to the worker thread by either: - inherit set of parent thread permissions - use limited subset of parent thread permissions - revoke all permissions (full sandbox) In order to achieve this functionality "CliModuleLoader" was modified to accept "initial permissions", which are used for top module loading (ie. uses parent thread permission set to load top level module of a worker).
2020-12-15fix(cli): make dynamic import errors catchable (#8750)Kitson Kelly
Fixes #6259
2020-12-13refactor: deno_runtime crate (#8640)Bartek Iwańczuk
This commit moves Deno JS runtime, ops, permissions and inspector implementation to new "deno_runtime" crate located in "runtime/" directory. Details in "runtime/README.md". Co-authored-by: Ryan Dahl <ry@tinyclouds.org>
2020-12-07refactor(cli): Simplify choosing type lib in CliModuleLoader (#8637)Bartek Iwańczuk