0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-10-31 09:14:20 -04:00
Commit graph

139 commits

Author SHA1 Message Date
Bartek Iwańczuk
96ea5b1d3d
refactor: deno_core not using std::env::current_dir (#18173)
This commit changes "deno_core" to not rely on implicitly calling
"std::env::current_dir()" when resolving module specifiers using
APIs from "deno_core::modules_specifier".

Supersedes https://github.com/denoland/deno/pull/15454
2023-03-14 16:47:09 -04:00
Yoshiya Hinosawa
e80cc17dc4
fix(ext/node): add crypto.createCipheriv (#18091) 2023-03-14 15:59:23 +09:00
Bartek Iwańczuk
e8f22c0765
refactor(core): pass cwd explicitly to resolve_path (#18092)
Towards landing #15454
2023-03-13 18:50:23 +01:00
Yoshiya Hinosawa
cd8a8993f1
chore(ext/node): copy internal/crypto/types.ts from std (#18156) 2023-03-14 00:18:07 +09:00
denobot
857393d934
chore: forward v1.31.2 release commit to main (#18114)
Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
2023-03-10 17:39:29 +09:00
Bartek Iwańczuk
8f207c0f3f
refactor: Split extension registration for runtime and snapshotting (#18095)
This commit splits "<ext_name>::init" functions into "init_ops" and
"init_ops_and_esm". That way we don't have to construct list of
ESM sources on each startup if we're running with a snapshot.

In a follow up commit "deno_core" will be changed to not have a split
between "extensions" and "extensions_with_js" - it will be embedders'
responsibility to pass appropriately configured extensions.

Prerequisite for https://github.com/denoland/deno/pull/18080
2023-03-09 14:56:19 +00:00
Bartek Iwańczuk
c3cba7f22c
refactor(core): Extension::builder_with_deps (#18093)
Prerequisite for https://github.com/denoland/deno/pull/18080
2023-03-09 12:10:54 +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
Bartek Iwańczuk
d24c6ea27f
refactor(runtime): conditionally register Extension with source files (#18068)
Since we are snapshotting extension source at build time, there's no
need to define list of sources for the extension at runtime.

This commit changes "deno_node" extension by removing "init_polyfill"
function in favor of "init_polyfill_ops_and_esm()" and "init_polyfill_ops()".

The former is used during snapshot and when "deno_runtime" is compiled
with "dont_create_runtime_snapshot" cargo feature flag. The latter is used
when running a worker from an existing snapshot.

This is a start of a bigger refactor to all extensions - thanks to this
change, we don't have to iterate over all defined source files for extension at
runtime, and because of that we don't have to create a filepath for each of the
source files. It's not a big deal, but we are iterating over 300 files on each start,
and concatenating 3 strings before creating a "PathBuf" for ~200 of them.
This is already visible on the startup flamegraphs and should be avoided.
2023-03-08 12:43:26 +01:00
Bartek Iwańczuk
b32a6f8ad2
refactor(core): don't use Result in ExtensionBuilder::state (#18066)
There's no point for this API to expect result. If something fails it should
result in a panic during build time to signal to embedder that setup is
wrong.
2023-03-07 22:37:37 +01:00
Bartek Iwańczuk
fe368b72c1
refactor: Add "deno_fs" extension crate (#18040)
This commit factors out APIs related to file system from "runtime/"
to a separate "deno_fs" extension crate.
2023-03-07 18:13:44 +09:00
Divy Srivastava
eea742ec6a
fix(ext/node): remove unused _hex module (#18045) 2023-03-06 09:57:32 +05:30
Divy Srivastava
4451fa857b
perf(ext/node): improve createHash performance (#18033)
```
> deno run -A ../test.mjs
cpu: unknown
runtime: deno 1.31.1 (aarch64-apple-darwin)

benchmark      time (avg)             (min … max)       p75       p99      p995
------------------------------------------------- -----------------------------
             2.22 µs/iter      (2.2 µs … 2.28 µs)   2.22 µs   2.28 µs   2.28 µs

> target/release/deno run -A test.mjs
cpu: unknown
runtime: deno 1.31.1 (aarch64-apple-darwin)

benchmark      time (avg)             (min … max)       p75       p99      p995
------------------------------------------------- -----------------------------
            864.9 ns/iter   (825.05 ns … 1.22 µs) 864.93 ns   1.22 µs   1.22 µs
```
2023-03-06 08:58:04 +05:30
Bartek Iwańczuk
1ab16e2426
refactor(core): InternalModuleLoader checks if all files were used (#18005)
This commit changes "InternalModuleLoader" from "deno_core" to 
store a list of used modules during snapshotting. If a module was not
used during snapshotting "InternalModuleLoader" will panic in its "Drop"
handler signaling to the embedder that they made a mistake somewhere.
2023-03-05 22:42:52 +00:00
Bartek Iwańczuk
5f34c9be91
refactor: move definition of Deno.build from "runtime" to "core" (#18036)
We use information about build in several extension crates like
"ext/node" or "runtime/". In an effort to move "fs" APIs to a separate 
crate it is a prerequisite to have this information available outside 
of the "runtime/" crate.

This commit moves definition of "build" object to "Deno.core" that is 
later forwarded to "Deno.build".
2023-03-05 22:18:13 +00:00
Divy Srivastava
c9c782940e
chore(ext/node): cleanup empty internal_bindings (#18032) 2023-03-05 10:53:42 -04:00
Bartek Iwańczuk
888ceac7fd
refactor(runtime): remove 40_files.js, 40_write_file.js and 40_read_file.js (#18018)
JavaScript APIs from "runtime/js/40_files.js" combined abstractions
for stdio streams ("Stdout", "Stderr", "Stdin") and file system file
("File", "FsFile"). APIs from "runtime/js/40_read_file.js" and 
"runtime/js/40_write_file.js" were implemented using ops from 
"runtime/ops/fs.rs".

This file was removed and relevant APIs were moved to "deno_io/12_io.js"
and "runtime/js/30_fs.js".

This work is meant to enable factoring out "deno_fs" crate.
2023-03-05 03:37:37 +00:00
Bartek Iwańczuk
b40086fd7d
refactor(core): include_js_files! 'dir' option doesn't change specifiers (#18019)
This commit changes "include_js_files!" macro from "deno_core"
in a way that "dir" option doesn't cause specifiers to be rewritten 
to include it.

Example:
```
include_js_files! {
  dir "js",
  "hello.js",
}
```

The above definition required embedders to use:
`import ... from "internal:<ext_name>/js/hello.js"`. 
But with this change, the "js" directory in which the files are stored
is an implementation detail, which for embedders results in: 
`import ... from "internal:<ext_name>/hello.js"`.

The directory the files are stored in, is an implementation detail and 
in some cases might result in a significant size difference for the 
snapshot. As an example, in "deno_node" extension, we store the 
source code in "polyfills" directory; which resulted in each specifier 
to look like "internal:deno_node/polyfills/<module_name>", but with 
this change it's "internal:deno_node/<module_name>". 

Given that "deno_node" has over 100 files, many of them having 
several import specifiers to the same extension, this change removes
10 characters from each import specifier.
2023-03-05 02:31:38 +00:00
Geert-Jan Zwiers
58ec963bf1
refactor: simplify to string calls (#18011) 2023-03-04 08:05:07 -04:00
David Sherret
6ffbf8a941
chore: fix cargo build rebuilding deno_runtime each time (#17978) 2023-02-28 19:24:55 +00:00
Geert-Jan Zwiers
6bbb4c3af6
chore(ext/node): fix variable name (#17948) 2023-02-27 21:26:02 +01:00
Yoshiya Hinosawa
29a62e81dd
refactor(ext/node): remove _process/stdio.js (#17911) 2023-02-26 12:19:00 +09:00
Yoshiya Hinosawa
3187e4e909
fix(ext/node): util.types.isSharedArrayBuffer (#17836) 2023-02-26 11:23:53 +09:00
denobot
3cd24fa8d0
chore: forward v1.31.1 release commit to main (#17939)
Co-authored-by: David Sherret <dsherret@gmail.com>
2023-02-24 22:37:46 -05:00
denobot
c26fbe38d5
1.31.0 (#17906)
Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-02-24 00:16:04 +01:00
David Sherret
344317ec50
feat(npm): support bare specifiers from package.json in more subcommands and language server (#17891) 2023-02-23 10:58:10 -05:00
Yoshiya Hinosawa
6de815859b
fix(ext/node): fix npm module resolution when --node-modules-dir specified (#17896) 2023-02-23 22:28:12 +09: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
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
Yoshiya Hinosawa
a2d942a778
fix(ext/node): fix node stream (#17874) 2023-02-22 23:30:58 +09:00
Yoshiya Hinosawa
860b6cbd23
fix(ext/node): fix webcrypto export (#17838) 2023-02-22 12:40:36 +09:00
Yoshiya Hinosawa
608c855f11
fix(ext/node): fix process.uptime (#17839) 2023-02-22 00:14:15 +09: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
Leo Kettmeir
88f6fc6a16
refactor: use ops for idna & punycode (#17817)
Towards https://github.com/denoland/deno/issues/17809
2023-02-20 18:47:42 +01:00
Divy Srivastava
ea7ca00c89
perf: use ops for node:crypto ciphers (#17819)
Towards #17809
2023-02-20 22:22:28 +05:30
Bartek Iwańczuk
a1cd2a5915
refactor(core): definition of "ExtensionFileSource" (#17823)
This commit changes definition of "ExtensionFileSource", by changing
"code" field to being "ExtensionFileSourceCode" enum. Currently the enum
has only a single variant "IncludedInBinary". It is done in preparation
to allow embedders to decide if they want to include the source code in the
binary when snapshotting (in most cases they shouldn't do that).

In the follow up commit we'll add more variants to
"ExtensionFileSourceCode".

"include_js_files_dir!" macro was removed in favor "include_js_files!"
macro which can now accept "dir" option.
2023-02-20 01:11:56 +01:00
Yoshiya Hinosawa
a01af067d7
test: add node compat tests (#17805) 2023-02-17 23:58:52 +09:00
Bartek Iwańczuk
1a7666a6ca
chore: remove unneeded files from ext/node (#17810) 2023-02-17 15:58:31 +01:00
Divy Srivastava
f8435d20b0
feat(ext/node): implement node:v8 (#17806)
Closes https://github.com/denoland/deno/issues/17115 

Implements `cachedDataVersionTag` and `getHeapStatistics`.
2023-02-17 18:48:09 +05:30
AntonioFCG
7ce1a68637
fix(ext/node): add support for BYOB streams (#17803) 2023-02-17 18:14:59 +09:00
Divy Srivastava
0aeb8bc759
perf(ext/node): move winerror binding to rust (#17792)
16873 lines of JS removed from the snapshot.
2023-02-16 19:19:32 +05:30
Bartek Iwańczuk
4c2380af5c
test: add unit tests from std/node (#17794)
Adds two test files: "cli/tests/unit_node/process_test.ts" and
"cli/tests/unit_node/child_process_test.ts"

---------

Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
2023-02-16 14:30:14 +01: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
Bartek Iwańczuk
d47147fb6a
feat(ext/node): embed std/node into the snapshot (#17724)
This commit moves "deno_std/node" in "ext/node" crate. The code is
transpiled and snapshotted during the build process.

During the first pass a minimal amount of work was done to create the
snapshot, a lot of code in "ext/node" depends on presence of "Deno"
global. This code will be gradually fixed in the follow up PRs to migrate
it to import relevant APIs from "internal:" modules.

Currently the code from snapshot is not used in any way, and all
Node/npm compatibility still uses code from 
"https://deno.land/std/node" (or from the location specified by 
"DENO_NODE_COMPAT_URL"). This will also be handled in a follow 
up PRs.

---------

Co-authored-by: crowlkats <crowlkats@toaxl.com>
Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
2023-02-14 17:38:45 +01: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
Bartek Iwańczuk
ed3a7ce2f7
refactor: allow to provide polyfills for Node modules from the snapshot (#17706)
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-10 11:40:45 +00:00
Kamil Ogórek
ef9b66950f
fix: use static Reflect methods in nodeGlobalThis proxy (#17696)
Co-authored-by: David Sherret <dsherret@gmail.com>
2023-02-08 19:11:12 -05:00
Leo Kettmeir
49af1ab18d
refactor: remove prefix from include_js_files & use extension name (#17683) 2023-02-07 21:09:50 +00:00
Leo Kettmeir
b4aa153097
refactor: Use ES modules for internal runtime code (#17648)
This PR refactors all internal js files (except core) to be written as
ES modules.
`__bootstrap`has been mostly replaced with static imports in form in
`internal:[path to file from repo root]`.
To specify if files are ESM, an `esm` method has been added to
`Extension`, similar to the `js` method.
A new ModuleLoader called `InternalModuleLoader` has been added to
enable the loading of internal specifiers, which is used in all
situations except when a snapshot is only loaded, and not a new one is
created from it.

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-02-07 20:22:46 +01:00
denobot
a4988d00da
chore: forward v1.30.3 release commit to main (#17677)
Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-02-07 04:15:38 +00:00