summaryrefslogtreecommitdiff
path: root/cli/module_loader.rs
AgeCommit message (Collapse)Author
2024-02-10chore: deno_core bump (#22379)Matt Mastracci
- Updates to V8 12.1.285.27 https://github.com/denoland/rusty_v8/pull/1383 - Swaps Box for Rc for `source_map_getter`
2024-02-07refactor: extract out `runtime::colors` to `deno_terminal::colors` (#22324)David Sherret
2024-02-01refactor: load bytes in deno_graph (#22212)David Sherret
Upgrades deno_graph to 0.64 where deno_graph is now responsible for turning bytes into a string. This is in preparation for Wasm modules.
2024-01-27refactor(cli): decouple resolvers from `module_loader.rs` for standalone use ↵Divy Srivastava
(#22147) It makes it easier to write a standalone bin target for `deno compile` without pulling a lot of the tooling and tsc loader logic
2024-01-27chore: upgrade deno_core to 0.256.0 (#22145)Divy Srivastava
2024-01-14chore: upgrade deno_core to 0.246.0 (#21904)Bartek Iwańczuk
2024-01-13fix(check): should not panic when all specified files excluded (#21929)David Sherret
Closes #21926
2024-01-10chore: bump deno_core (#21832)Matt Mastracci
2024-01-09fix: update deno_lint and swc (#21718)Bartek Iwańczuk
Co-authored-by: David Sherret <dsherret@gmail.com>
2024-01-08perf: skip expanding exclude globs (#21817)David Sherret
We were calling `expand_glob` on our excludes, which is very expensive and unnecessary because we can pattern match while traversing instead. 1. Doesn't expand "exclude" globs. Instead pattern matches while walking the directory. 2. Splits up the "include" into base paths and applicable file patterns. This causes less pattern matching to occur because we're only pattern matching on patterns that might match and not ones in completely unrelated directories.
2024-01-03fix(cli): respect `exclude` option for `deno check` command (#21779)nokazn
This PR fixes #21658. - `check` subcommand sees `exclude` option in `deno.json`. When some paths passed with `check` command listed in `exclude`, they are ignored. - When some files are listed in `exclude` and imported indirectly among module graph, they are checked.
2024-01-03chore: upgrade deno_core to 0.241.0 (#21765)Bartek Iwańczuk
2024-01-01chore: update copyright to 2024 (#21753)David Sherret
2023-12-08feat(lsp): provide quick fixes for specifiers that could be resolved ↵David Sherret
sloppily (#21506)
2023-12-07feat: add suggestions to module not found error messages for file urls (#21498)David Sherret
2023-12-07feat(unstable): ability to resolve specifiers with no extension, specifiers ↵David Sherret
for a directory, and TS files from JS extensions (#21464) Adds an `--unstable-sloppy-imports` flag which supports the following for `file:` specifiers: * Allows writing `./mod` in a specifier to do extension probing. - ex. `import { Example } from "./example"` instead of `import { Example } from "./example.ts"` * Allows writing `./routes` to do directory extension probing for files like `./routes/index.ts` * Allows writing `./mod.js` for *mod.ts* files. This functionality is **NOT RECOMMENDED** for general use with Deno: 1. It's not as optimal for perf: https://marvinh.dev/blog/speeding-up-javascript-ecosystem-part-2/ 1. It makes tooling in the ecosystem more complex in order to have to understand this. 1. The "Deno way" is to be explicit about what you're doing. It's better in the long run. 1. It doesn't work if published to the Deno registry because doing stuff like extension probing with remote specifiers would be incredibly slow. This is instead only recommended to help with migrating existing projects to Deno. For example, it's very useful for getting CJS projects written with import/export declaration working in Deno without modifying module specifiers and for supporting TS ESM projects written with `./mod.js` specifiers. This feature will output warnings to guide the user towards correcting their specifiers. Additionally, quick fixes are provided in the LSP to update these specifiers:
2023-12-01feat(compile): support discovering modules for more dynamic arguments (#21381)David Sherret
This PR causes Deno to include more files in the graph based on how a template literal looks that's provided to a dynamic import: ```ts const file = await import(`./dir/${expr}`); ``` In this case, it will search the `dir` directory and descendant directories for any .js/jsx/etc modules and include them in the graph. To opt out of this behaviour, move the template literal to a separate line: ```ts const specifier = `./dir/${expr}` const file = await import(specifier); ```
2023-11-17feat(unstable): Workspaces support (#20410)Bartek Iwańczuk
This commit adds unstable workspace support. This is extremely bare-bones and minimal first-pass at this. With this change `deno.json` supports specifying `workspaces` key, that accepts a list of subdirectories. Each workspace can have its own import map. It's required to specify a `"name"` and `"version"` properties in the configuration file for the workspace: ```jsonc // deno.json { "workspaces": [ "a", "b" }, "imports": { "express": "npm:express@5" } } ``` ``` jsonc // a/deno.json { "name": "a", "version": "1.0.2", "imports": { "kleur": "npm:kleur" } } ``` ```jsonc // b/deno.json { "name": "b", "version": "0.51.0", "imports": { "chalk": "npm:chalk" } } ``` `--unstable-workspaces` flag is required to use this feature: ``` $ deno run --unstable-workspaces mod.ts ``` --------- Co-authored-by: David Sherret <dsherret@gmail.com>
2023-10-25refactor: break out ModuleInfoCache from ParsedSourceCache (#20977)David Sherret
As title. This will help use the two independently from the other, which will help in an upcoming deno doc PR where I need to parse the source files with scope analysis.
2023-10-25feat(unstable): ability to `npm install` then `deno run main.ts` (#20967)David Sherret
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.
2023-10-24fix: improved using declaration support (#20959)David Sherret
Upgrades to deno_ast 0.30.
2023-10-20feat(unstable): allow bare specifier for builtin node module (#20728)Yoshiya Hinosawa
closes #20566
2023-10-05refactor(npm): add referrer when resolving npm package sub path from deno ↵David Sherret
module (#20800) Adds a `referrer` parameter to this function instead of using a fake one.
2023-10-03refactor(npm): break up `NpmModuleLoader` and move more methods into the ↵David Sherret
managed `CliNpmResolver` (#20777) Part of https://github.com/denoland/deno/issues/18967
2023-09-29refactor(cli): make `CliNpmResolver` a trait (#20732)David Sherret
This makes `CliNpmResolver` a trait. The terminology used is: - **managed** - Deno manages the node_modules folder and does an auto-install (ex. `ManagedCliNpmResolver`) - **byonm** - "Bring your own node_modules" (ex. `ByonmCliNpmResolver`, which is in this PR, but unimplemented at the moment) Part of #18967
2023-09-28refactor(ext/node): remove dependency on deno_npm and deno_semver (#20718)David Sherret
This is required from BYONM (bring your own node_modules). Part of #18967
2023-09-16feat: Add "deno jupyter" subcommand (#20337)Bartek Iwańczuk
This commit adds "deno jupyter" subcommand which provides a Deno kernel for Jupyter notebooks. The implementation is mostly based on Deno's REPL and reuses large parts of it (though there's some clean up that needs to happen in follow up PRs). Not all functionality of Jupyter kernel is implemented and some message type are still not implemented (eg. "inspect_request") but the kernel is fully working and provides all the capatibilities that the Deno REPL has; including TypeScript transpilation and npm packages support. Closes https://github.com/denoland/deno/issues/13016 --------- Co-authored-by: Adam Powers <apowers@ato.ms> Co-authored-by: Kyle Kelley <rgbkrk@gmail.com>
2023-09-07feat: support import attributes (#20342)David Sherret
2023-08-08chore: rename some helpers on the Fs trait (#20097)Luca Casonato
Rename some of the helper methods on the Fs trait to be suffixed with `_sync` / `_async`, in preparation of the introduction of more async methods for some helpers. Also adds a `read_text_file_async` helper to complement the renamed `read_text_file_sync` helper.
2023-08-01fix(ext/node): fix import json using npm specifier (#19723)await-ovo
2023-07-31refactor: NodeCodeTranslator - optional source to translate_cjs_to_esm (#20000)David Sherret
2023-07-19feat(ext/node): properly segregate node globals (#19307)Luca Casonato
Code run within Deno-mode and Node-mode should have access to a slightly different set of globals. Previously this was done through a compile time code-transform for Node-mode, but this is not ideal and has many edge cases, for example Node's globalThis having a different identity than Deno's globalThis. This commit makes the `globalThis` of the entire runtime a semi-proxy. This proxy returns a different set of globals depending on the caller's mode. This is not a full proxy, because it is shadowed by "real" properties on globalThis. This is done to avoid the overhead of a full proxy for all globalThis operations. The globals between Deno-mode and Node-mode are now properly segregated. This means that code running in Deno-mode will not have access to Node's globals, and vice versa. Deleting a managed global in Deno-mode will NOT delete the corresponding global in Node-mode, and vice versa. --------- Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com> Co-authored-by: Aapo Alasuutari <aapo.alasuutari@gmail.com>
2023-07-14fix(npm): improve error message on directory import in npm package (#19538)Elian Cordoba
Co-authored-by: David Sherret <dsherret@users.noreply.github.com>
2023-06-14fix: reload config files on watcher restarts (#19487)David Sherret
Closes #19468
2023-06-07refactor: helpers methods on `TypeCheckMode` (#19393)David Sherret
2023-05-31refactor(core): don't pass op state to prepare_module_load() (#19332)Nayeem Rahman
It's not used anymore. Subsequently allows removing `ModuleMap::op_state`, allowing `ModuleMap` to have a sane default so `JsRuntime::module_map` no longer needs to be optional.
2023-05-28refactor(core): remove ext: modules from the module map (#19040)Nayeem Rahman
Rather than disallowing `ext:` resolution, clear the module map after initializing extensions so extension modules are anonymized. This operation is explicitly called in `deno_runtime`. Re-inject `node:` specifiers into the module map after doing this. Fixes #17717.
2023-05-22fix(npm): store npm binary command resolution in lockfile (#19219)David Sherret
Part of #19038 Closes #19034 (eliminates the time spent re-resolving)
2023-05-10feat(compile): unstable npm and node specifier support (#19005)David Sherret
This is the initial support for npm and node specifiers in `deno compile`. The npm packages are included in the binary and read from it via a virtual file system. This also supports the `--node-modules-dir` flag, dependencies specified in a package.json, and npm binary commands (ex. `deno compile --unstable npm:cowsay`) Closes #16632
2023-05-01refactor(cli): remove ProcState - add CliFactory (#18900)David Sherret
This removes `ProcState` and replaces it with a new `CliFactory` which initializes our "service structs" on demand. This isn't a performance improvement at the moment for `deno run`, but might unlock performance improvements in the future.
2023-05-01refactor(cli): use CliMainWorker in standalone (#18880)David Sherret
Uses `CliMainWorker` in all the cli code.
2023-04-27refactor(cli): extract out ProcState from CliMainWorker (#18867)David Sherret
2023-04-26feat(cli): don't check permissions for statically analyzable dynamic imports ↵Nayeem Rahman
(#18713) Closes #17697 Closes #17658
2023-04-25refactor(cli): extract out NpmModuleLoader from CliModuleLoader (#18842)David Sherret
Need to share this with the loader used in deno compile
2023-04-24refactor(ext/node): enforce interior mutable for `NodePermissions` to remove ↵David Sherret
clones (#18831) We can make `NodePermissions` rely on interior mutability (which the `PermissionsContainer` is already doing) in order to not have to clone everything all the time. This also reduces the chance of an accidental `borrow` while `borrrow_mut`.
2023-04-24refactor(ext/node): allow injecting `NodeFs` from CLI (#18829)David Sherret
This allows providing a `NodeFs` as part of the `WorkerOptions`.
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: add `TypeChecker` struct (#18709)David Sherret
Adds a `TypeChecker` struct and pushes more shared functionality into it.