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

443 commits

Author SHA1 Message Date
Nayeem Rahman
845d4754c6
fix(check): use "moduleDetection": "force" (#14875) 2022-06-15 12:26:43 -04:00
cjihrig
b2109a12aa fix(url): properly indent when inspecting URLs (#14867)
This commit updates the custom inspect function for URL objects
to pass the inspect options through so that the context is
propagated and the resulting indentation is correct.

Fixes: https://github.com/denoland/deno/issues/14171
2022-06-15 09:52:28 -04:00
Mark Ladyshau
d4f609d8e7
feat(test): update test summary report (#14629) 2022-06-14 20:51:49 +02:00
David Sherret
443041c23e
feat(vendor): support using an existing import map (#14836) 2022-06-14 10:05:37 -04:00
Bartek Iwańczuk
fc3a966a2d
Deno.exit() is an alias to self.close() in worker contexts (#14826)
This commit changes Deno.exit() to be an alias to self.close() in worker contexts,
and the provided exit code becomes is ignored.
2022-06-13 23:53:04 +02:00
Bartek Iwańczuk
4a0a412d7c
feat: no type-check by default (#14691)
This commit changes default default behavior of type checking
for several subcommands.

Instead of type checking and reporting type errors only for local
files, the type checking is skipped entirely. Type checking can
still be enabled using the "--check" flag.

Following subcomands are affected:
- deno cache
- deno install
- deno eval
- deno run
2022-06-13 23:13:16 +02:00
Mark Ladyshau
decdc59071
fix(cli): add config flag to deno info (#14706) 2022-06-13 20:09:04 +02:00
David Sherret
3dd981e199
feat(fmt): support formatting cjs, cts, mjs, and mts files (#14837) 2022-06-09 19:55:04 -04:00
Kayla Washburn
94068b7109
feat(task): add --cwd flag for configuring the working directory (#14823) 2022-06-08 15:30:16 -06:00
Bartek Iwańczuk
2769d60250
fix: watch dynamic imports in --watch (#14775)
Fix dynamic imports being watched in the watcher when using `--watch`.
2022-06-08 12:07:25 +02:00
Nayeem Rahman
e3eae662f3
fix: Format non-error exceptions (#14604)
This commit adds "Deno.core.setFormatExceptionCallback" which
can be used to provide custom formatting for errors. It is useful
in cases when user throws something that is non-Error (eg.
a string, plain object, etc).
2022-06-06 20:26:57 +02:00
Kitson Kelly
7eee521199
feat: update to TypeScript 4.7 (#14242) 2022-06-01 10:19:18 +10:00
David Sherret
b65d5024ef
fix: read raw stdin to prevent buffering (regression) (#14704) 2022-05-23 12:35:02 -04:00
David Sherret
69be1f3cf7
fix: deno task should actually use current exe for deno command (#14705) 2022-05-23 12:04:28 -04:00
Leo Kettmeir
3c97bbe165
fix(ext/websocket): WebSocket dispatch single close event (#13443) 2022-05-23 13:21:11 +02:00
Colin Ihrig
d55444b41c
fix(coverage): do not report transpiled files with no lines (#14699)
This commit omits files from the coverage report that have no
lines of code to report coverage for.

Fixes: https://github.com/denoland/deno/issues/14683
2022-05-22 10:45:22 -04:00
David Sherret
1fcecb6789
refactor: upgrade to deno_ast 0.15 (#14680) 2022-05-20 16:40:55 -04:00
Yoshiya Hinosawa
e7c894e8f5
fix: prevent Deno.exit to fail when dispatchEvent tampered (#14665)
Co-authored-by: Colin Ihrig <cjihrig@gmail.com>
2022-05-20 11:57:05 +09:00
Leo Kettmeir
4e1ca1d178
refactor: use spawn API across codebase (#14414) 2022-05-18 22:00:11 +02:00
Aleksei Kosyrev
037466e9cd
fix(ext/tls): ability to ignore IP-address certificate errors (#14610) 2022-05-18 13:32:12 +02:00
Bartek Iwańczuk
9a85a95c43
feat: subcommands type-check only local files by default (#14623)
This commit changes default mode of type-checking to "local" 
and adds "--check" flag to following subcommands:
- deno bench
- deno bundle
- deno cache
- deno compile
- deno eval
- deno install
- deno test
2022-05-17 23:53:42 +02:00
Bartek Iwańczuk
f57aac77ff
BREAKING: Remove unstable Deno.emit and Deno.formatDiagnostics APIs (#14463) 2022-05-17 13:50:31 -04:00
Divy Srivastava
68bf43fca7
feat(core): deterministic snapshots (#14037) 2022-05-17 20:49:55 +05:30
David Sherret
eb5ffab1cb
fix(lsp): correct positions in some scenarios (#14359) 2022-05-15 14:41:37 -04:00
Thanapat Chotipun
bd4256262a
feat(ext/net): add support for SOA records in Deno.resolveDns() API (#14534) 2022-05-14 14:08:35 +02:00
Bartek Iwańczuk
939a070c8c
feat: add --no-config flag (#14555)
This flag disables loading of configuration file, ie. it will not be
automatically discovered and loaded. Of course this flag conflicts
with "--config" flag and they cannot be used together.
2022-05-13 17:40:50 +02:00
Bartek Iwańczuk
b543e84b39
chore: update test_util/std/ submodule (#14595) 2022-05-13 17:08:02 +02:00
David Sherret
e6d8775611
chore: fix flaky lsp_testing_api test (#14569) 2022-05-11 15:44:15 -04:00
David Sherret
0ea6b51bf0
fix: stdout and stderr encoding on Windows (#14559) 2022-05-11 12:48:38 -04:00
Nayeem Rahman
cb884de2e9
fix(runtime/web_worker): Use biased select when getting module result (#14553) 2022-05-10 11:26:57 +02:00
Nayeem Rahman
23efc4fcab
feat(test): Represent uncaught errors (#14513)
This commit adds better reporting of uncaught errors
in top level scope of testing files. This change affects
both console runner as well as LSP runner.
2022-05-09 11:44:50 +02:00
Aaron O'Mullan
d0f5cd6a06
fix(core): avoid panic on non-string Error.name (#14529)
Fixes #14518
2022-05-08 23:03:00 +02:00
Geert-Jan Zwiers
253fbf9d2a
fix(coverage): exclude .snap files (#14480) 2022-05-04 13:10:55 +02:00
Thanapat Chotipun
e3954df8c5
feat(ext/net): add "NS" record support in Deno.resolveDns API (#14372) 2022-05-03 20:04:20 +02:00
Adilson Schmitt Junior
256dcb058a
fix(test/bench): accept file protocol module specifier CLI args (#14429) 2022-05-02 15:43:03 -04:00
David Sherret
de33017a8b
fix(test): actually capture stdout and stderr in workers (#14435) 2022-05-01 14:44:55 -04:00
Kitson Kelly
ef26a267ae
fix(cli): add dom.extras lib (#14430)
Closes: #12558
Fixes: #14344
2022-04-29 13:47:58 +10:00
Andreu Botella
ba799b6729
fix(workers): Make worker.terminate() not block the current thread (#13941)
Calling `worker.terminate()` used to kill the worker's isolate and
then block until the worker's thread finished. This blocks the calling
thread if the worker's event loop was blocked in a sync op (as with
`Deno.sleepSync`), which wasn't realized at the time, but since the
worker's isolate was killed at that moment, it would not block the
calling thread if the worker was in a JS endless loop.

However, in #12831, in order to work around a V8 bug, worker
termination was changed to first set a signal to let the worker event
loop know that termination has been requested, and only kill the
isolate if the event loop has not finished after 2 seconds. However,
this change kept the blocking, which meant that JS endless loops in
the worker now blocked the parent for 2 seconds.

As it turns out, after #12831 it is fine to signal termination and
even kill the worker's isolate without waiting for the thread to
finish, so this change does that. However, that might leave the async
ops that receive messages and control data from the worker pending
after `worker.terminate()`, which leads to odd results from the op
sanitizer. Therefore, we set up a `CancelHandler` to cancel those ops
when the worker is terminated.
2022-04-27 18:22:47 +02:00
Nayeem Rahman
9853c96cc4
refactor: Remove PrettyJsError and js_error_create_fn (#14378)
This commit:
- removes "fmt_errors::PrettyJsError" in favor of "format_js_error" fn
- removes "deno_core::JsError::create" and 
"deno_core::RuntimeOptions::js_error_create_fn"
- adds new option to "deno_runtime::ops::worker_host::init"
2022-04-27 01:06:10 +02:00
David Sherret
58eab0e2b3
fix(test): capture worker stdout and stderr in test output (#14410) 2022-04-26 19:00:04 -04:00
David Sherret
a1b4aa2ae6
fix(test): capture inherited stdout and stderr for subprocesses in test output (#14395) 2022-04-26 14:46:49 -04:00
David Sherret
f07f246ae8
chore: fix pty_complete_imports test (#14400) 2022-04-26 09:53:22 -04:00
Nayeem Rahman
e9041b9edc
fix(runtime/js/spawn): Pass stdio options for spawn() and spawnSync() (#14358) 2022-04-24 17:21:22 +02:00
evan
602097ab6e
fix(bench): report pending summary before clearing (#14369) 2022-04-23 14:20:28 +02:00
David Sherret
4cc5b2126a
chore(tests): fix pty_clear_function on Windows (#14364) 2022-04-22 17:49:10 -04:00
evan
6fad5c33c9
fix(bench): reset reporter context (#14360)
This commit fixes previous file benchmarks leaking into the next file benchmarks summary.
2022-04-22 13:43:22 +02:00
Bartek Iwańczuk
db13e455ec
fix(watcher): don't clear screen on start (#14351) 2022-04-21 17:21:59 +02:00
Colin Ihrig
2a93c134dc
feat(repl): add global clear() function (#14332)
This commit adds a clear() function in the REPL which works
similar to console.clear().
2022-04-20 15:48:15 -04:00
evan
f785ecee1a
feat(bench): update API, new console reporter (#14305)
This commit changes "deno bench" subcommand, by updating
the "Deno.bench" API as follows:
- remove "Deno.BenchDefinition.n"
- remove "Deno.BenchDefintion.warmup"
- add "Deno.BenchDefinition.group"
- add "Deno.BenchDefintion.baseline"

This is done because bench cases are no longer run fixed amount
of iterations, but instead they are run until there is difference between
subsequent runs that is statistically insiginificant.

Additionally, console reporter was rewritten completely, to looks
similar to "hyperfine" reporter.
2022-04-20 21:06:39 +02:00
Naju Mancheril
3833d37b15
feat(repl): add "--eval-file" flag to execute a script file on startup (#14247)
This commit adds support for "--eval-file" in "deno repl" subcommand.

This flag can be used to pass paths or URLs to files, that will be executed
on REPL startup. All files will be executed in the same context as the REPL
(ie. as "plain old scripts", not ES modules), sharing the global scope.

This feature allows to implement custom REPLs on top of Deno's REPL.
2022-04-20 14:16:37 +02:00
Divy Srivastava
1c05e41f37
perf(runtime): bypass tokio file and bump op buffer size to 64K (#14319) 2022-04-19 20:11:31 +05:30
Nayeem Rahman
c30d95f2e3
feat(ext/web): add globalThis.reportError() (#13799) 2022-04-19 10:59:51 +02:00
Nayeem Rahman
66fbdd2ed4
feat: Add DENO_NO_PROMPT variable (#14209)
This commit adds support for "DENO_NO_PROMPT" env
variable, that can be used instead of "--no-prompt" flag
to completely disable permission prompts.
2022-04-18 21:08:30 +02:00
Nayeem Rahman
2f29673fb2
fix(cli/emit): Check JS roots with // @ts-check (#14090) 2022-04-18 16:52:26 +02:00
Bartek Iwańczuk
9c5928b5aa
fix: panic when trying to pledge permissions before restoring previous pledge (#14306)
This commit fixes and edge case, where testing/benching code could pledge new
permission set before restoring the previous pledge.

Appropriate panics were added and tests that assert that process is killed
in case of "recursive pledge".
2022-04-17 17:47:24 +02:00
Bartek Iwańczuk
a87be28a46
feat: Better formatting for AggregateError (#14285)
This commit adds "aggregated" field to "deno_core::JsError" that stores
instances of "JsError" recursively to properly handle "AggregateError"
formatting. Appropriate logics was added to "PrettyJsError" and
"console" API to format AggregateErrors.

Co-authored-by: Nayeem Rahman <nayeemrmn99@gmail.com>
2022-04-16 16:12:26 +02:00
Nayeem Rahman
8b31fc23cd
refactor: Move source map lookups to core (#14274)
The following transformations gradually faced by "JsError" have all been 
moved up front to "JsError::from_v8_exception()": 

- finding the first non-"deno:" source line; 
- moving "JsError::script_resource_name" etc. into the first error stack 
in case of syntax errors; 
- source mapping "JsError::script_resource_name" etc. when wrapping 
the error even though the frame locations are source mapped earlier; 
- removing "JsError::{script_resource_name,line_number,start_column,end_column}"
entirely in favour of "js_error.frames.get(0)". 

We also no longer pass a js-side callback to "core/02_error.js" from cli. 
I avoided doing this on previous occasions because the source map lookups 
were in an awkward place.
2022-04-15 16:08:09 +02:00
Bartek Iwańczuk
244926e83c
feat(test): format user code output (#14271)
This commit changes "deno test" to better denote user output coming
from test cases.

This is done by printing "---- output ----" and "---- output end ----"
markers if an output is produced. The output from "console" and
"Deno.core.print" is captured, as well as direct writes to "Deno.stdout"
and "Deno.stderr".

To achieve that new APIs were added to "deno_core" crate, that allow
to replace an existing resource with a different one (while keeping resource
ids intact). Resources for stdout and stderr are replaced by pipes.

Co-authored-by: David Sherret <dsherret@gmail.com>
2022-04-15 14:24:41 +02:00
Nayeem Rahman
4d18f558e4
feat(ext/web): Add error events for event listener and timer errors (#14159)
- feat: Add handleable error event for even listener errors
- feat: Add handleable error event for setTimeout()/setInterval() errors
- feat: Add Deno.core.destructureError()
- feat: Add Deno.core.terminate()
- fix: Don't throw listener errors from dispatchEvent()
- fix: Use biased mode when selecting between mod_evaluate() and
  run_event_loop() results
2022-04-13 11:50:57 +02:00
Bartek Iwańczuk
c8313a7457
feat(test): Improve testing report output (#14255)
Following changes were done in this commit:

- remove "test" prefix before each test
- use gray color for "running N tests from ..." prompt
- use relative path or remote URL instead of full URL in "running N tests from ..." prompt
- in "failures" section, add file path/remote URL before the test name

Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
2022-04-11 18:27:17 +02:00
Bartek Iwańczuk
8ae17026cb
feat: Add "deno check" subcommand for type checking (#14072)
This commit adds new "deno check" subcommand.
Currently it is an alias for "deno cache" with the difference that remote
modules don't emit TS diagnostics by default.

Prints warning for "deno run" subcommand if "--check" flag is not present
and there's no "--no-check" flag. Adds "DENO_FUTURE_CHECK" env
variable that allows to opt into new behavior now.
2022-04-11 01:12:51 +02:00
David Sherret
a4c1e1bdcf
fix: upgrade to swc_ecmascript 0.143 (#14238) 2022-04-08 12:31:47 -04:00
Jason
a6e4b4297d
refactor(lsp): migrate from lspower back to tower-lsp (#14163) 2022-04-03 14:17:30 +10:00
David Sherret
1535fdd949
chore: fix main (#14175) 2022-04-01 11:49:16 -04:00
David Sherret
1c37ac3352
chore(tests): use custom temp dir creation for the tests (#14153) 2022-04-01 11:15:37 -04:00
Divy Srivastava
b0f974fbfd
fix(compile): follow redirects when resolving (#14161) 2022-03-31 14:11:30 +05:30
David Sherret
d069360c46
chore(tests): add more lsp tests for formatting (#14155) 2022-03-30 18:44:47 -04:00
Kitson Kelly
061090de7e
feat(lsp): add experimental testing API (#13798)
Ref: denoland/vscode_deno#629
2022-03-30 09:59:27 +11:00
TrickyPi
85e16a08c7
feat(cli/fmt): ignore .git folder when formatting files (#14138) 2022-03-29 14:57:42 -04:00
Kitson Kelly
5a6a1eeb39
feat(lsp): support API for config file (#14139)
Closes: #13910
2022-03-29 11:27:43 +11:00
David Sherret
89dd5dac62
chore: fix compile_windows_ext test (#14142) 2022-03-28 14:38:15 -04:00
Luca Casonato
25b73a366f
fix(ext/ffi): enforce unstable check on ops (#14115) 2022-03-25 12:29:54 +01:00
Kitson Kelly
c755548e02
tests(cli): ignore previously unignored test (#14104)
Ref: #14103
2022-03-24 12:45:45 +11:00
Bartek Iwańczuk
b82ded84d3
fix(bench): require --unstable flag in JavaScript (#14091) 2022-03-23 16:33:42 +01:00
Bartek Iwańczuk
c3f306d778
fix(test): don't error on missing op details (#14074) 2022-03-23 00:24:45 +01:00
David Sherret
6268a1a6fd
chore: replace .expect("...") calls with .unwrap() in test code (#14081) 2022-03-22 15:10:00 -04:00
David Sherret
e46b5f738d
fix(tests): do not use global env vars in install tests (#14078) 2022-03-22 13:37:15 -04:00
Nayeem Rahman
d2c099ce34
fix(ext/fetch): Connect async error stack with user code (#13899) 2022-03-22 18:08:33 +01:00
Andreu Botella
12d28dffc6
fix(fetch): Fix uncaught rejection panic with WebAssembly.instantiateStreaming (#13925)
When an exception is thrown during the processing of streaming WebAssembly,
`op_wasm_streaming_abort` is called. This op calls into V8, which synchronously
rejects the promise and calls into the promise rejection handler, if applicable.
But calling an op borrows the isolate's `JsRuntimeState` for the duration of the
op, which means it is borrowed when V8 calls into `promise_reject_callback`,
which tries to borrow it again, panicking.

This change changes `op_wasm_streaming_abort` from an op to a binding
(`Deno.core.abortWasmStreaming`). Although that binding must borrow the
`JsRuntimeState` in order to access the `WasmStreamingResource` stored in the
`OpTable`, it also takes ownership of that `WasmStreamingResource` instance,
which means it can drop any borrows of the `JsRuntimeState` before calling into
V8.
2022-03-22 11:33:29 +01:00
David Sherret
b410937556
chore: fix development issues on Windows (#14030) 2022-03-21 14:30:43 +01:00
Kitson Kelly
1414dc503b
feat(lsp): support deno.enablePaths setting (#13978)
Ref: denoland/vscode_deno#633
2022-03-21 12:33:37 +11:00
TrickyPi
b01bc7faff
fix(cli): improve deno compile error messages (#13944)
Co-authored-by: David Sherret <dsherret@gmail.com>
2022-03-18 19:18:50 -04:00
David Sherret
748aff1e94
feat(task): add unstable warning to deno task (#13966) 2022-03-15 21:24:07 -04:00
Ryan Dahl
163e1d6192
disable flakes (#13962) 2022-03-15 11:19:59 -04:00
Bartek Iwańczuk
9d9e60b694
feat(task): log task script (#13922)
Logs task name and associated script with additional args.
This is disabled if "--quiet/-q" flag is present.
2022-03-12 02:35:18 +01:00
Bartek Iwańczuk
1a764790f2
test: fix flaky compat tests (#13921) 2022-03-12 02:08:55 +01:00
Bartek Iwańczuk
09ae512ccb
feat: "deno bench" subcommand (#13713)
This commit adds "deno bench" subcommand and "Deno.bench()"
API that allows to register bench cases. 

The API is modelled after "Deno.test()" and "deno test" subcommand.

Currently the output is rudimentary and bench cases and not
subject to "ops" and "resource" sanitizers.

Co-authored-by: evan <github@evan.lol>
2022-03-11 23:07:02 +01:00
Bartek Iwańczuk
47f22777be
feat: "deno task" subcommand (#13725)
Co-authored-by: David Sherret <dsherret@gmail.com>
2022-03-10 20:56:14 -05:00
Bartek Iwańczuk
808f797633
fix(compat): cjs/esm interop for dynamic imports (#13792)
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-03-11 02:33:02 +01:00
Geert-Jan Zwiers
8db3a9546b
fix(test): skip typechecking for blocks inside HTML comments (#13889) 2022-03-11 02:14:32 +01:00
Geert-Jan Zwiers
e53b6c16bc
fix(test): typecheck blocks annotated with long js/ts notations (#13785) 2022-03-08 02:10:40 +01:00
Yoshiya Hinosawa
b751e97a01
fix(repl): fix null eval result (#13804)
Co-authored-by: Satya Rohith <me@satyarohith.com>
2022-03-02 13:39:08 +09:00
Bartek Iwańczuk
a65ce33fab
feat(compat): CJS/ESM interoperability (#13553)
This commit adds CJS/ESM interoperability when running in --compat mode.

Before executing files, they are analyzed and all CommonJS modules are
transformed on the fly to a ES modules. This is done by utilizing analyze_cjs()
functionality from deno_ast. After discovering exports and reexports, an ES
module is rendered and saved in memory for later use.

There's a caveat that all files ending with ".js" extension are considered as
CommonJS modules (unless there's a related "package.json" with "type": "module").
2022-02-27 14:38:45 +01:00
Bartek Iwańczuk
4bea1d06c7
fix(test): use --no-prompt by default (#13777)
This commit changes "deno test" subcommand, to
always never prompt for permissions (ie. as if "deno test"
was run with "--no-prompt" flag).
2022-02-26 14:49:50 +01:00
Bartek Iwańczuk
d332bf1132
feat: deno test --trace-ops (#13770)
This commit adds "--trace-ops" flag to "deno test" subcommand.

This flag enables saving of stack traces for async ops, that before were always
saved. While the feature proved to be very useful it comes with a significant performance
hit, it's caused by excessive source mapping of stack frames.
2022-02-25 16:14:46 +01:00
Yoshiya Hinosawa
111c343281
fix(cli): disable config discovery for remote script (#13745) 2022-02-25 14:39:18 +09:00
Divy Srivastava
03c55b4970
fix(compile): Support import maps (#13756) 2022-02-24 18:58:00 +05:30
Kitson Kelly
ee27b9dd7e
feat: allow specification of import map in config file (#13739)
Closes: #12800
2022-02-23 10:51:14 +11:00
Ryan Dahl
57f4b0e5af
feat: Add hint to permission prompt to display allow flag (#13695) 2022-02-17 00:14:46 +01:00
David Sherret
b98afb59ae
feat: deno vendor (#13670) 2022-02-16 13:14:19 -05:00
Luca Casonato
be9c2fe267
tests: deflake a bunch of net related tests (#13685) 2022-02-16 16:51:32 +01:00
William Tetlow
7b893bd57f
feat(cli): Replace bundling with eszip in deno compile (#13563)
Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
2022-02-15 18:03:46 +05:30
Ryan Dahl
a5d204d425
feat: permission prompt by default (#13650) 2022-02-12 22:13:21 -05:00
Bartek Iwańczuk
2fa0096821
compat: support --compat in web workers (#13629)
Adds another callback to WebWorkerOptions that allows to execute
some modules before actual worker code executes. This allows to set up Node
global using std/node.
2022-02-11 13:41:56 +01:00
Kitson Kelly
2f2c778a07
feat(lsp): support linking to symbols in JSDoc on hover (#13631)
Closes #13198
2022-02-10 10:08:53 +11:00
Kitson Kelly
773f882e5e
feat(lsp): provide completions from import map if available (#13624)
Closes #13619
2022-02-10 07:13:50 +11:00
Leo Kettmeir
4799aaac15
refactor: factor out CDP message types (#13551) 2022-02-07 17:05:49 +01:00
Kitson Kelly
af5a373e00
feat(lsp): add redirect diagnostic and quick fix (#13580)
Ref: #12864
2022-02-04 18:14:57 +11:00
Luca Casonato
681c3be18d
fix: don't crash when $HOME is a relative path (#13581)
Absolutize the cache/home dir before use in DenoDir.
2022-02-03 14:08:17 +01:00
David Sherret
ed3086e4b1
refactor(lsp): remove circular dependency between LanguageServer and DiagnosticsServer (#13577) 2022-02-02 18:02:59 -05:00
Kitson Kelly
de5a4a1757
fix(cli): handle local files with query params on emit (#13568)
Fixes #13562
2022-02-03 06:48:54 +11:00
Zheyu Zhang
5490cfed20
feat(cli): add "--no-clear-screen" flag (#13454)
This commit adds "--no-clear-screen" flag which can be used
with "--watch" flag to disable clearing of terminal screen on
each file change.
2022-01-31 17:39:39 +01:00
Kitson Kelly
68c8c66b0f
fix(cli): handle extensionless imports better (#13548)
Fixes #13526
2022-01-31 20:32:49 +11:00
Luca Casonato
b53997273d
feat(test): better errors for resource sanitizer (#13296)
This commit makes the errors produced from the resource sanitizer much
more human readable. It does this by using real words rather than our
"resource names" when referring to resources, and by giving helpful
hints on how to clean up each of the resources.
2022-01-25 17:03:38 +01:00
David Sherret
2f72c44e1d
fix(lsp): independent diagnostic publishing should include all diagnostic sources on each publish (#13483) 2022-01-24 18:04:24 -05:00
David Sherret
bc8de78da3
perf(lsp): independent diagnostic source publishes (#13427) 2022-01-24 15:30:01 -05:00
Bartek Iwańczuk
23d2b34d4b
tests: Add inspector tests for "Memory" and "Profile" tabs (#13476) 2022-01-24 16:07:08 +01:00
Kitson Kelly
3ec248cff8
fix(lsp): respect DENO_CERT and other options related to TLS certs (#13467)
Fixes #13437
2022-01-24 11:27:52 +11:00
David Sherret
0f3a53e5d4
feat: stabilize test steps API (#13400) 2022-01-18 15:02:56 -05:00
Ryan Dahl
39ea4abff4
feat: auto-discover config file (#13313) 2022-01-17 20:10:17 -05:00
Bartek Iwańczuk
b10563cb20
fix(runtime): don't crash when window is deleted (#13392)
This commit fixes an error when user deletes "window" global JS
variable. Instead of relying on "window" or "globalThis" to dispatch
"load" and "unload" events, we are default to global scope of the
worker.
2022-01-18 00:13:14 +01:00
Bartek Iwańczuk
bc666e42a8
fix(ext/console): don't depend on globalThis present (#13387) 2022-01-17 23:23:49 +01:00
Andreu Botella
9def44979a
fix(cli): Don't strip shebangs from modules (#13220)
Deno's module loader currently strips a shebang if a module file
starts with one. However, this is no longer necessary, since there is
a stage-3 TC39 that adds support for shebangs (or "hashbangs") to the
language (https://github.com/tc39/proposal-hashbang), and V8, `tsc`
and `swc` all support it.

Furthermore, stripping shebangs causes a correctness bug with JSON
modules, since a JSON file with a shebang should not parse as a JSON
module, yet it does with this stripping. This change fixes this.
2022-01-16 16:48:32 +01:00
Bartek Iwańczuk
dc58063d00
test: type check lib.deno_core.d.ts (#13356) 2022-01-14 19:05:16 +01:00
juju
50e8ab8a86
feat(cli): add ignore directives to bundled code (#13309)
This commit adds lint and fmt ignore directives to bundled
code as well as a comment stating that the code was bundled
and shouldn't be edited manually.
2022-01-12 13:05:06 +01:00
Bartek Iwańczuk
13751d9de6
fix(coverage): merge coverage ranges (#13334)
Covered ranges were not merged and thus it appeared that some lines
might be uncovered. To fix this I used "v8-coverage" that takes care
of merging the ranges properly. With this change, coverage collected
from a file by multiple entrypoints is now correctly calculated.

I ended up forking https://github.com/demurgos/v8-coverage and adding
"cli/tools/coverage/merge.rs" and "cli/tools/coverage/range_tree.rs".
2022-01-11 21:17:25 +01:00
Rabin Gaire
605b8db8f6
cli(compile): fix output flag behaviour on compile command (#13299) 2022-01-10 23:24:39 -05:00
Bartek Iwańczuk
a3b3a792b5
fix(coverage): don't type check (#13324)
This commit changes "deno coverage" command not to type check.

Instead of relying on infrastructure for module loading in "deno run";
the code now directly reaches into cache for original and transpiled
sources. In case sources are not available the error is returned to the
user, suggesting to first run "deno test --coverage" command.
2022-01-10 17:36:58 +01:00
Bartek Iwańczuk
bd53567acf
test: add inspector test with ts files (#13312) 2022-01-09 17:44:36 +01:00
Ryan Dahl
1fb5858009
chore: update copyright to 2022 (#13306)
Co-authored-by: Erfan Safari <erfanshield@outlook.com>
2022-01-07 22:09:52 -05:00
Kitson Kelly
57bfa87b2c
feat(lsp): provide registry details on hover if present (#13294)
Closes: #13272
2022-01-07 11:27:13 +11:00
Leo Kettmeir
2067820714
feat(ext/websocket): server automatically handle ping/pong for incoming WebSocket (#13172) 2022-01-06 17:41:16 +01:00
VishnuJin
d9b130410b
feat(compat) preload Node.js built-in modules in global vars REPL (#13127)
This commit adds preloading of built-in Node.js modules in
the REPL if running with "deno repl --compat --unstable".
2022-01-03 20:10:17 +01:00
Steven Guerrero
39a6c94071
feat(test): Add support for "deno test --compat" (#13235) 2021-12-30 17:18:30 +01:00
Bartek Iwańczuk
1adf8ee545
fix(core): inspector works if no "Runtime.runIfWaitingForDebugger" message is sent (#13191)
This commit changes flow in inspector code to no longer require 
"Runtime.runIfWaitingForDebugger" message to complete a handshake.

Even though clients like Chrome DevTools always send this message on startup,
it is against the protocol to require this message to start an inspector
session.

Instead "Runtime.runIfWaitingForDebugger" is required only when running with
"--inspect-brk" flag, which matches behavior of Node.js.
2021-12-30 16:47:58 +01:00
Leo Kettmeir
167982be9e
feat: output cause on JS runtime errors (#13209) 2021-12-29 19:34:13 +01:00
David Sherret
7ebbda7fd7
fix(coverage): use only string byte indexes and 0-indexed line numbers (#13190) 2021-12-23 20:02:54 -05:00
Kitson Kelly
37dbe5249c
fix(cli): include JSON modules in bundle (#13188)
Fixes #13150
2021-12-24 09:38:20 +11:00
Kitson Kelly
8547a37132
chore: update deno_graph and deno_doc (#13173) 2021-12-22 14:25:06 +01:00
David Sherret
ac06797fa8
chore(tests): remove pty_complete_imports test for deleting the cwd (#13164) 2021-12-21 12:21:07 -05:00
Bartek Iwańczuk
f3cd9a94b5
fix: inspector prompts (#13123)
This commit fixes prompts printed to the terminal when
running with "--inspect" or "--inspect-brk" flags.

When debugger disconnects error is no longer printed as
users don't care about the reason debugger did disconnect.

A message suggesting to go to "chrome://inspect" is printed
if debugger is active.

Additionally and information that process is waiting for
debugger to connect is printed if running with "--inspect-brk"
flag.
2021-12-17 18:43:25 +01:00
Nayeem Rahman
9ffc7edc23
refactor(cli): use GraphData for check and emit (#12960) 2021-12-16 21:45:41 +11:00
Kitson Kelly
e28fb70aee
fix(lsp): provide diagnostics for import assertions (#13105)
Fixes: #13099
2021-12-16 14:53:17 +11:00
Jesper van den Ende
0f53b82cd2
fix(test): wait for inspector session in side modules (#13065)
This commit fixes inspector integration with "deno test" subcommand
by waiting for inspector sessions to connect if "--inspect-brk" flag
is passed.

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2021-12-16 00:38:27 +01:00
Jesper van den Ende
5a3ded6611
feat(watch): support watching external files (#13087) 2021-12-15 16:04:43 -05:00
David Sherret
6c324acf23
feat: REPL import specifier auto-completions (#13078) 2021-12-15 13:23:43 -05:00
Bartek Iwańczuk
a1f0796fcc
feat: Add support for import assertions and JSON modules (#12866)
This commit adds proper support for import assertions and JSON modules.

Implementation of "core/modules.rs" was changed to account for multiple possible
module types, instead of always assuming that the code is an "ES module". In
effect "ModuleMap" now has knowledge about each modules' type (stored via
"ModuleType" enum). Module loading pipeline now stores information about
expected module type for each request and validates that expected type matches
discovered module type based on file's "MediaType".

Relevant tests were added to "core/modules.rs" and integration tests,
additionally multiple WPT tests were enabled.

There are still some rough edges in the implementation and not all WPT were
enabled, due to:
a) unclear BOM handling in source code by "FileFetcher"
b) design limitation of Deno's "FileFetcher" that doesn't download the same
module multiple times in a single run

Co-authored-by: Kitson Kelly <me@kitsonkelly.com>
2021-12-15 19:22:36 +01:00
Yoshiya Hinosawa
308813ae29
fix(ext/web): set location undefined when --location is not specified (#13046) 2021-12-14 00:35:59 +09:00
Bartek Iwańczuk
0dec9b4381
fix: op_set_exit_code (#13034)
Fixes "op_set_exit_code" by sharing a single "Arc" between
all workers (via "op state") instead of having a "global" value stored in
"deno_runtime" crate. As a consequence setting an exit code is always
scoped to a tree of workers, instead of being overridable if there are
multiple worker tree (like in "deno test --jobs" subcommand).

Refactored "cli/main.rs" functions to return "Result<i32, AnyError>" instead
of "Result<(), AnyError>" so they can return exit code.
2021-12-11 15:56:45 +01:00
Bartek Iwańczuk
13d7d57227
feat(watcher): clear screen on each restart (#12613)
This commit adds automatic clearing of terminal screen after
restarting execution on file change.
2021-12-11 01:12:25 +01:00
David Sherret
f530189c50
fix(watch): mitigate race condition between file write by other process and watch read (#13038) 2021-12-09 20:24:37 -05:00
Kitson Kelly
345f0fbe5c
feat(cli): update to TypeScript 4.5 (#12410)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2021-12-10 09:12:21 +11:00
David Sherret
1507b8c984
fix: upgrade swc fixing many bundling and --no-check bugs (#13025) 2021-12-08 19:12:14 -05:00
Andreu Botella
33da15ae5a
refactor(timers): refactor timers to use one async op per timer (#12862)
This change also makes the timers implementation closer to the spec, and
sets up the stage to implement AbortSignal.timeout() (whatwg/dom#1032).

Fixes #8965
Fixes #10974
Fixes #11398
2021-12-07 13:39:58 +01:00
Ryan Dahl
a2f1357fe8
chore: upgrade to rustls 0.20 (#12488)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: Bert Belder <bertbelder@gmail.com>
2021-12-07 00:48:11 +01:00
Andreu Botella
9a10668694
fix(test): Improve reliability of deno test's op sanitizer with timers (#12934)
Although not easy to replicate in the wild, the `deno test` op sanitizer
can fail when there are intervals that started before a test runs, since
the op sanitizer can end up running in the time between the timer op for
an interval's run resolves and the op for the next run starts.

This change fixes that by adding a new macrotask callback that will run
after the timer macrotask queue has drained. This ensures that there is
a timer op if there are any timers which are unresolved by the time the
op sanitizer runs.
2021-11-30 01:27:30 +01:00
Kitson Kelly
18a63dd977
feat: add --no-check=remote flag (#12766)
Closes #11970
2021-11-30 09:23:30 +11:00
Andreu Botella
4a13c320d7
fix(workers): Make worker.terminate() not immediately kill the isolate (#12831)
Due to a bug in V8, terminating an isolate while a module with top-level
await is being evaluated would crash the process. This change makes it
so calling `worker.terminate()` will signal the worker to terminate at
the next iteration of the event loop, and it schedules a proper
termination of the worker's isolate after 2 seconds.
2021-11-29 13:37:44 +01:00
Bartek Iwańczuk
5178e093ed
Revert "fix(test): Improve reliability of deno test's op sanitizer with timers (#12908)" (#12929)
This reverts commit d335343a79.
2021-11-29 12:07:47 +01:00
Andreu Botella
d335343a79
fix(test): Improve reliability of deno test's op sanitizer with timers (#12908)
Although not easy to replicate in the wild, the `deno test` op sanitizer
can fail when there are intervals that started before a test runs, since
the op sanitizer can end up running in the time between the timer op for
an interval's run resolves and the op for the next run starts.

This change fixes that by adding a new macrotask callback that will run
after the timer macrotask queue has drained. This ensures that there is
a timer op if there are any timers which are unresolved by the time the
op sanitizer runs.
2021-11-28 16:40:38 +01:00
Ben Noordhuis
993a1dd41a
feat(runtime): add op_set_exit_code (#12911)
Set the exit code to use if none is provided to Deno.exit(), or when
Deno exits naturally.

Needed for process.exitCode Node compat. Paves the way for #12888.
2021-11-28 00:45:38 +01:00
Bartek Iwańczuk
e68a241946
chore: upgrade lspower to 1.4.0 (#12894) 2021-11-25 12:10:12 +11:00
David Sherret
adc5974333
fix(lsp): lsp should respect include/exclude files in format config (#12876) 2021-11-24 15:14:19 -05:00
Bartek Iwańczuk
1117d2db39
compat: support compat mode in REPL (#12882)
This commit introduces "ProcState::maybe_resolver" field, which
stores a single instance of resolver for the whole lifetime of the
process, instead of creating these resolvers for each creation
of module graph. As a result, this resolver can be used in fallback
case where graph is not constructed (REPL, loading modules using
"require") unifying resolution logic.
2021-11-24 16:55:10 +01:00
Bartek Iwańczuk
1a51f2392d
chore: speed up compat tests (#12884)
This commit speeds up compat tests by using local copy of "deno_std"
instead of downloading it from https://deno.land for each test.
Additionally type checking is skipped.
2021-11-24 12:24:13 +01:00
Zheyu Zhang
fd6d0e309c
fix(cli/compile): skip bundling for pre-bundled code (#12687) 2021-11-23 23:59:17 +01:00
Nayeem Rahman
7413c96985
fix(cli): don't cache .tsbuildinfo unless emitting (#12830)
Fixes #12755
Fixes #12807
Fixes #12832
2021-11-24 08:20:30 +11:00
Bartek Iwańczuk
d2c53e7f10
tests: remove 'fmt_check_tests_dir' test (#12875) 2021-11-23 18:36:13 +01:00
Bartek Iwańczuk
d8afd56838
feat(test): Add more overloads for "Deno.test" (#12749)
This commit adds 4 more overloads to "Deno.test()" API.

```
// Deno.test(function testName() { });
export function test(fn: (t: TestContext) => void | Promise<void>): void;

// Deno.test("test name", { only: true }, function() { });
export function test(
  name: string,
  options: Omit<TestDefinition, "name">,
  fn: (t: TestContext) => void | Promise<void>,
): void;

// Deno.test({ name: "test name" }, function() { });
export function test(
  options: Omit<TestDefinition, "fn">,
  fn: (t: TestContext) => void | Promise<void>,
): void;

// Deno.test({ only: true }, function testName() { });
export function test(
  options: Omit<TestDefinition, "fn" | "name">,
  fn: (t: TestContext) => void | Promise<void>,
): void;
```
2021-11-23 14:57:51 +01:00
Kitson Kelly
210300d049
feat(lsp): add type definition provider (#12789) 2021-11-23 11:09:19 +11:00
Kitson Kelly
bf5657cd59
feat(lsp): add workspace symbol provider (#12787) 2021-11-23 11:08:56 +11:00
Kitson Kelly
14f83da221
fix(lsp): tag deprecated diagnostics properly (#12801) 2021-11-18 13:05:20 +11:00
Kitson Kelly
cc38580106
fix(lsp): retain module dependencies when parse is invalid (#12782)
Fixes #12753
2021-11-17 09:23:25 +11:00
Yacine Hmito
f9f9ddc5e3
tests(lsp): regression test for providing completions when editing documents (#12776)
Ref: #12753
2021-11-16 13:59:33 +11:00
Nayeem Rahman
cd9193f126
fix(cli): short-circuit in prepare_module_load() (#12604) 2021-11-16 10:25:52 +11:00
Geert-Jan Zwiers
58e7b290dc
fix(test): support typechecking docs with CRLF line endings (#12748) 2021-11-15 09:58:04 -05:00
Kitson Kelly
f5eb177f50
feat(cli): support React 17 JSX transforms (#12631)
Closes #8440
2021-11-09 12:26:39 +11:00
Yoshiya Hinosawa
8e010b6844
feat(compat): add .code to dyn import error (#12633) 2021-11-08 16:02:40 +09:00
Kitson Kelly
182de1452b
fix(lsp): display module types only dependencies on hover (#12683)
Fixes: #12675
2021-11-08 11:50:48 +11:00
Luca Casonato
b6b25671b2
fix(lsp): display signature docs as markdown (#12636)
These were previously displayed as plain text. Now they are displayed as
`MarkupContent` with type `Markdown`.
2021-11-07 23:26:11 +01:00
Zheyu Zhang
efe956b4fd
fix(lint): use recommended tag if there is no tags in config file or flags (#12644) 2021-11-04 11:12:12 -04:00
Luca Casonato
318dcc33af
Revert "feat(cli): enable useUnknownInCatchVariables by default" (#12643)
This partially reverts commit a065604155.

Co-authored-by: Kitson Kelly <me@kitsonkelly.com>
2021-11-04 11:30:37 +01:00
Ryan Dahl
7c2abb9d57
fix: Deno.emit crashes with BorrowMutError (#12627)
Warn on await_holding_refcell_ref clippy rule to avoid this in the future.

Fixes #12453
2021-11-03 09:27:36 -04:00
David Sherret
2794d0b7a2
fix(fmt/lint): strip unc paths on Windows when displaying file paths in lint and fmt (#12606) 2021-11-01 16:22:08 -04:00
Zheyu Zhang
3fb23ab772
fix(cli): linter/formater watches current directory without args (#12550) 2021-10-30 19:20:56 +02:00
Zheyu Zhang
85a2943435
fix(cli): lint/format all discoverd files on each change (#12518) 2021-10-30 09:59:53 +02:00
Kitson Kelly
34a9ddff09
refactor(lsp): use deno_graph and single document struct (#12535)
Closes #12473
2021-10-29 10:56:01 +11:00
Bartek Iwańczuk
f77c5701f7
feat(compat): integrate import map and classic resolutions in ESM resolution (#12549)
This commit integrates import map and "classic" resolutions in
the "--compat" mode when using ES modules; in effect
"http:", "https:" and "blob:" imports now work in compat mode.

The algorithm works as follows:

1. If there's an import map, try to resolve using it and if succeeded
return the specifier
2. Try to resolve using "Node ESM resolution", and if succeeded return
the specifier
3. Fall back to regular ESM resolution
2021-10-28 10:11:38 +02:00
Kitson Kelly
a065604155
feat(cli): enable useUnknownInCatchVariables by default (#12547)
Closes #11826

**BREAKING CHANGE** this behaviour was disable when introduced in Deno 1.14/TypeScript 4.4. It will highlight code that unsafely handles variables that are caught, and will cause type errors in unsafe code.
2021-10-28 08:43:40 +11:00
Kitson Kelly
1c739470b5
feat(ext/webstorage): use implied origin when --location not set (#12548)
Closes #11882

BREAKING CHANGE: Previously when `--location` was set, the unique storage key was derived from the the URL of the location instead of just the origin. This change correctly uses just the origin. This may cause previously persisted storage to change its key and data to not be available with the same location as before.
2021-10-27 11:10:27 +11:00
Kitson Kelly
56d9a020d9
fix(cli): do not cache emit when diagnostics present (#12541)
Fixes #12471
2021-10-26 10:34:16 +11:00
Bartek Iwańczuk
8a0e206ede
compat: add DENO_NODE_COMPAT_URL env variable (#12508) 2021-10-21 00:23:57 +02:00
Nayeem Rahman
e8ee5da459
fix(core/bindings): use is_instance_of_error() instead of is_native_error() (#12479) 2021-10-19 18:26:45 +02:00
Bartek Iwańczuk
617eeabe83
feat(unstable): Node CJS and ESM resolvers for compat mode (#12424)
This commit adds CJS and ESM Node resolvers to the "--compat" mode.

The functionality is spread across "cli/compat" module and Node compatibility
layer in "deno_std/node"; this stems from the fact that ES module resolution
can only be implemented in Rust as it needs to directly integrated with 
"deno_core"; however "deno_std/node" already provided CJS module resolution.

Currently this resolution is only active when running a files using 
"deno run --compat --unstable <filename>", and is not available in other
subcommands, which will be changed in follow up commits.
2021-10-18 19:36:28 +02:00
Nayeem Rahman
5a48d41bdd
fix(cli/fmt_errors): don't panic on source line formatting errors (#12449)
Returns empty values in case of errors, source lines are non-essential anyway. These errors can happen e.g. when source files change at runtime. A warning is also printed to help us track when it happens in unexpected cases besides this.
2021-10-18 18:05:36 +02:00
Nayeem Rahman
7a22df9b76
fix(runtime/ops/worker_host): move permission arg parsing to Rust (#12297) 2021-10-13 13:04:44 -04:00
David Sherret
43a63530ac
chore: test for bundling export specifier with alias (#12421) 2021-10-13 08:55:28 -04:00
Bartek Iwańczuk
f332d72f16
fix(lsp): lint diagnostics respect config file (#12338)
This commit fixes problem with LSP where diagnostics coming
from "deno lint" don't respect configuration file.

LSP was changed to store "Option<ConfigFile>", "Option<LintConfig>"
and "Option<FmtConfig>" on "Inner"; as well as storing "Option<LintConfig>"
and "Option<FmtConfig>" on "StateSnapshot".

Co-authored-by: Kitson Kelly <me@kitsonkelly.com>
2021-10-12 00:02:33 +02:00
Bartek Iwańczuk
5508a0f45e
feat(compat): pin specific version of std/node (#12396) 2021-10-11 23:14:46 +02:00
Andreu Botella
fbcbbd7ae3
fix(runtime): Declare Window.self and DedicatedWorkerGlobalScope.name with util.writable() (#12378)
`Window`'s `self` property and `DedicatedWorkerGlobalScope`'s `name`
property are defined as Web IDL read-only attributes with the
`[Replaceable]` extended attribute, meaning that their setter will
redefine the property as a data property with the set value, rather than
changing some internal state. Deno currently defines them as read-only
data properties instead.

Given that Web IDL requires all attributes to be accessor properties
rather than data properties, but Deno exposes almost all of those
properties as either read-only or writable data properties, it makes
sense to expose `[Replaceable]` properties as writable as well – as is
already the case with `WindowOrWorkerGlobalScope`'s `performance`
property.
2021-10-11 18:50:18 +02:00