1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-01 09:24:20 -04:00
Commit graph

490 commits

Author SHA1 Message Date
Bartek Iwańczuk
aba5329aec
refactor(ext/node): make initialization functions sync (#18282)
These functions don't need to be async, as they are only calling
synchronous JavaScript code. As a follow up, all 3 functions
should be merge together - this will reduce roundtrips for
calling V8 from Rust, which is somewhat expensive
2023-03-20 00:40:21 -04:00
Andreu Botella
b64ec79268
feat(compile): Enable multiple roots for a standalone module graph (#17663)
This change will enable dynamic imports and web workers to use modules
not reachable from the main module, by passing a list of extra side
module roots as options to `deno compile`. 

This can be done by specifying "--include" flag that accepts a file path or a
URL. This flag can be specified multiple times, to include several modules.
The modules specified with "--include" flag, will be added to the produced
"eszip".
2023-03-19 00:43:07 +01:00
Matt Mastracci
e55b448730
feat(core) deno_core::extension! macro to simplify extension registration (#18210)
This implements two macros to simplify extension registration and centralize a lot of the boilerplate as a base for future improvements:

* `deno_core::ops!` registers a block of `#[op]`s, optionally with type
parameters, useful for places where we share lists of ops
* `deno_core::extension!` is used to register an extension, and creates
two methods that can be used at runtime/snapshot generation time:
`init_ops` and `init_ops_and_esm`.

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-03-17 18:22:15 +00:00
Roy Li
2c7174a5a2
fix(repl): Hide indexable properties in tab completion (#18141)
Closes #17831. This change hides the indices of any indexed collection
when triggering tab completion for object properties in the REPL.

An example is shown in the issue, but for verbosity here is another.

Before the change:
```
> const arr = new Uint8ClampedArray([1, 2, 3])
undefined
> arr.
0                     map
1                     reverse
2                     reduce
...
```
After the change:
```
> const arr = new Uint8ClampedArray([1, 2, 3])
undefined
> arr.
constructor               reduce
BYTES_PER_ELEMENT         reduceRight
buffer                    set
...
```

Co-authored-by: David Sherret <dsherret@users.noreply.github.com>
2023-03-16 19:46:50 +00:00
Nick Hanley
1a3c2e2f1d
feat(repl): add DENO_REPL_HISTORY to change history file path (#18047) 2023-03-17 01:22:24 +09:00
David Sherret
c1eba16b84
fix(repl): do not panic deleting Deno or deleting all its properties (#18211)
Closes #18194
Closes #12092
2023-03-15 21:41:13 -04:00
David Sherret
fb021d7cef
refactor: remove usages of map_or / map_or_else (#18212)
These methods are confusing because the arguments are backwards. I feel
like they should have never been added to `Option<T>` and that clippy
should suggest rewriting to
`map(...).unwrap_or(...)`/`map(...).unwrap_or_else(|| ...)`

https://github.com/rust-lang/rfcs/issues/1025
2023-03-15 17:46:36 -04:00
Divy Srivastava
51649272bd
perf: do not depend on iana-time-zone (#18088)
Chrono's `clock` feature pulls in `iana-time-zone` which links to macOS
core_foundation. This PR itself is not enough to get rid of
CoreFoundation. Removal depends on getting rid of security framework,
see #18071
2023-03-15 07:14:22 +00:00
Bartek Iwańczuk
9aa20b3ba7
refactor: --watch commands use deno_core::resolve_url_or_path (#18172)
This commit changes various CLI subcommands that have support for
the "--watch" flag to use initial current working directory when
resolving "main module". 

This is part of migration towards explicitly passing current working
directory to "deno_core::resolve_url_or_path" API.

As a side effect this makes "deno <subcommand> --watch" more aligned to
user expectations, where calling "Deno.chdir()" during program doesn't
break watcher.

Towards landing https://github.com/denoland/deno/pull/15454
2023-03-14 02:44:16 +00:00
Bartek Iwańczuk
48ede89f1f
refactor(core): resolve_url_or_path and resolve_url_or_path_deprecated (#18170)
This commit changes current "deno_core::resolve_url_or_path" API to
"resolve_url_or_path_deprecated" and adds new "resolve_url_or_path"
API that requires to explicitly pass the directory from which paths
should be resolved to. 

Some of the call sites were updated to use the new API, the reminder
of them will be updated in a follow up PR.

Towards landing https://github.com/denoland/deno/pull/15454
2023-03-14 01:12:09 +00:00
Bartek Iwańczuk
c4771356f2
refactor: Remove call sites of "deno_core::resolve_url_or_path" (#18169)
These call sites didn't need to use "resolve_url_or_path".

Towards landing https://github.com/denoland/deno/pull/15454
2023-03-13 19:31:03 -04:00
David Sherret
a35c8e6588
fix(info/doc): add missing --no-lock and --lock flags (#18166)
Closes #18159
2023-03-13 17:04:00 -04:00
David Sherret
8db853514c
fix(check): regression where config "types" entries caused type checking errors (#18124)
Closes #18117
Closes #18121 (this is just over 10ms faster in a directory one up from
the root folder)

cc @nayeemrmn
2023-03-11 11:43:45 -05:00
Bartek Iwańczuk
bb07e230d1
chore: update Rust to 1.68.0 (#18102) 2023-03-09 19:18:00 +00:00
Bartek Iwańczuk
72fe9bb470
refactor: rename InternalModuleLoader to ExtModuleLoader, use ext: scheme for snapshotted modules (#18041)
This commit renames "deno_core::InternalModuleLoader" to
"ExtModuleLoader" and changes the specifiers used by the 
modules loaded from this loader to "ext:".

"internal:" scheme was really ambiguous and it's more characters than
"ext:", which should result in slightly smaller snapshot size.

Closes https://github.com/denoland/deno/issues/18020
2023-03-08 12:44:54 +01:00
Nayeem Rahman
273777f7d9
fix(check): include dts files in tsc roots (#18026) 2023-03-05 12:47:04 -05:00
Bartek Iwańczuk
7afa3aceb0
refactor(runtime): factor out deno_io extension crate (#18001)
This is a prerequisite to factor out FS ops to a separate crate.
2023-03-05 00:39:48 +00:00
Geert-Jan Zwiers
58ec963bf1
refactor: simplify to string calls (#18011) 2023-03-04 08:05:07 -04:00
David Sherret
84bafd11d5
fix: lazily surface errors in package.json deps parsing (#17974)
Closes #17941
2023-03-03 18:27:05 -04:00
Yusuke Tanaka
88c9a999f7
chore(cli): update deno_lint to 0.41.0 (#17997)
<!--
Before submitting a PR, please read http://deno.land/manual/contributing

1. Give the PR a descriptive title.

  Examples of good title:
    - fix(std/http): Fix race condition in server
    - docs(console): Update docstrings
    - feat(doc): Handle nested reexports

  Examples of bad title:
    - fix #7123
    - update docs
    - fix bugs

2. Ensure there is a related issue and it is referenced in the PR text.
3. Ensure there are tests that cover the changes.
4. Ensure `cargo test` passes.
5. Ensure `./tools/format.js` passes without changing files.
6. Ensure `./tools/lint.js` passes.
7. Open as a draft PR if your work is still in progress. The CI won't
run
   all steps, but you can add '[ci]' to a commit message to force it to.
8. If you would like to run the benchmarks on the CI, add the 'ci-bench'
label.
-->

This commit updates deno_lint crate to 0.41.0. The new version contains
a braking change that requries a minor code fix here, which is also
addressed in this commit.
2023-03-02 21:50:17 +00:00
David Sherret
033b70af19
fix(npm): lazily install package.json dependencies only when necessary (#17931)
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-24 19:35:43 -05:00
Bartek Iwańczuk
4773d07974
feat(task): adjust warning (#17904)
Put it on a single line and remove coloring.
2023-02-23 20:43:18 +01:00
Bartek Iwańczuk
214bdbbc2b
feat(task): add warning about package.json scripts support (#17900) 2023-02-23 16:41:28 +01:00
Bartek Iwańczuk
d5f053dabf
feat(bench): change --json output format (#17888)
Closes https://github.com/denoland/deno/issues/17775
2023-02-23 12:59:23 +01:00
David Sherret
b15f9e60a0
feat(task): support scripts in package.json (#17887)
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-22 22:45:35 -05:00
David Sherret
ddc350780d
fix(npm): resolve node_modules dir relative to package.json instead of cwd (#17885) 2023-02-22 20:16:16 -05:00
Bartek Iwańczuk
1c14127c4f
feat: support bare specifier resolution with package.json (#17864)
This commit enables resolution of "bare specifiers" (eg. "import express
from 'express';") if a "package.json" file is discovered. 

It's a step towards being able to run projects authored for Node.js 
without any changes.

With this commit we are able to successfully run Vite projects without
any changes to the user code.

---------

Co-authored-by: David Sherret <dsherret@gmail.com>
2023-02-22 23:21:05 +01:00
David Sherret
a6ca4d0d61
refactor: use deno_graph for npm specifiers (#17858)
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-22 14:15:25 -05:00
David Sherret
3479bc7661
fix(npm): improve peer dependency resolution (#17835)
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-21 12:03:48 -05:00
Bartek Iwańczuk
4d1a14ca7f
feat: auto-discover package.json for npm dependencies (#17272)
This commits adds auto-discovery of "package.json" file when running
"deno run" and "deno task" subcommands. In case of "deno run" the
"package.json" is being looked up starting from the directory of the
script that is being run, stopping early if "deno.json(c)" file is found
(ie. FS tree won't be traversed "up" from "deno.json").

When "package.json" is discovered the "--node-modules-dir" flag is
implied, leading to creation of local "node_modules/" directory - we
did that, because most tools relying on "package.json" will expect
"node_modules/" directory to be present (eg. Vite). Additionally 
"dependencies" and "devDependencies" specified in the "package.json"
are downloaded on startup. 

This is a stepping stone to supporting bare specifier imports, but
the actual integration will be done in a follow up commit.

---------

Co-authored-by: David Sherret <dsherret@gmail.com>
2023-02-20 19:14:06 +01:00
David Sherret
610b8cc2bf
refactor: add NpmPackageId back from deno_graph as NpmPackageNodeId (#17804)
The `NpmPackageId` struct is being renamed to `NpmPackageNodeId`. In a
future PR it will be moved down into only npm dependency resolution and
a `NpmPackageId` struct will be introduced in `deno_graph` that only has
the name and version of the package (no peer dependency identifier
information). So a `NpmPackageReq` will map to an `NpmPackageId`, which
will map to an `NpmPackageNodeId` in the npm resolution.
2023-02-17 09:12:22 -05:00
Kamil Ogórek
6e1b737400
ref(cli): Add better error message when powershell is missing during upgrade (#17759)
Closes https://github.com/denoland/deno/issues/17756
2023-02-16 21:14:57 +02:00
Bartek Iwańczuk
75209e12f1
feat: wire up ext/node to the Node compatibility layer (#17785)
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-15 19:44:52 +01:00
David Sherret
c4b9a91e27
refactor: use deno_graph's semver and npm structs (#17791) 2023-02-15 13:20:40 -05:00
David Sherret
b34e751a5b
refactor: make resolver required (#17783)
Makes the resolver required and prints a warning when vendoring and a
dynamic import can't be resolved.

Closes #16522
2023-02-15 11:30:54 -05:00
Bartek Iwańczuk
0f1349bca8
feat: Deprecate 'deno bundle' subcommand (#17695)
This commit adds a deprecation warning when using "deno bundle"
subcommand and removes it from the output of "deno help".
2023-02-14 02:13:44 +01:00
Serhiy Barhamon
fc843d035c
feat(bench): Add JSON reporter for "deno bench" subcommand (#17595) 2023-02-12 17:40:45 +00:00
Bartek Iwańczuk
46817a0e3d
refactor: clean up "cli/node/mod.rs" and "ext/node" (#17713)
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-10 10:26:39 -05:00
Kamil Ogórek
5778e1196e
feat(install): follow redirects for urls with no path (#17449)
This change makes absolute urls, that contain no path like `deno install
https://my-cli.io` to follow redirects and extract the name from it.

It allows modifies `test_util` server listener on port `4550`
(`REDIRECT_ABSOLUTE_PORT`) to allow for specifying `redirect_to` query
param, that fill use that value for it's next redirect.

Fixes https://github.com/denoland/deno/issues/17409
2023-02-10 10:11:11 -05:00
David Sherret
b3e88e0681
refactor: deno_graph 0.43 upgrade (#17692) 2023-02-09 22:00:23 -05:00
David Sherret
8b0a612e30
perf: disable fetching graph cache info except for deno info (#17698) 2023-02-08 19:45:04 -05:00
Ikko Eltociear Ashimine
0597499e9e
chore(cli/tools): fix typo in upgrade.rs (#17690)
vesion -> version
2023-02-08 03:32:30 +00:00
Leo Kettmeir
84a96110cd
refactor: rename deno specifiers to internal (#17655) 2023-02-05 17:49:20 +01:00
Nayeem Rahman
a635c9700c
refactor: reland "preserve ProcState::file_fetcher between restarts" (#17636)
Just some watcher init step that I thought would be "cloned over" but
needs to be done again on reset.
2023-02-03 20:15:16 +01:00
David Sherret
dc854e83a4
fix(repl): handle @types/node not being cached in the repl (#17617)
Closes #17599
2023-02-01 16:37:05 -05:00
Bartek Iwańczuk
d318e38b76
Revert "fix(watch): preserve ProcState::file_fetcher between restarts (#15466) (#17591)
This reverts commit 3545bff678.
2023-01-30 16:22:17 +01:00
David Sherret
8b35229da3
fix(install): tsconfig.json -> deno.json for config file suffix (#17573)
Closes #17571
2023-01-28 14:51:11 -05:00
David Sherret
f5840bdcd3
chore: upgrade to Rust 1.67 (#17548)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-01-27 10:43:16 -05:00
David Sherret
21065797f6
fix(upgrade): ensure temp dir cleanup on failure (#17535)
Closes #17533
2023-01-26 09:02:25 -05:00
Bartek Iwańczuk
c6c8c91a6e
feat: embed import map in the config file (#17478)
This commit changes handling of config file to enable
specifying "imports" and "scopes" objects effectively making
the configuration file an import map.

"imports" and "scopes" take precedence over "importMap" configuration,
but have lower priority than "--importmap" CLI flag.

Co-authored-by: David Sherret <dsherret@users.noreply.github.com>
Co-authored-by: David Sherret <dsherret@gmail.com>
2023-01-25 21:13:40 +01:00