Commit graph

114 commits

Author SHA1 Message Date
Kitson Kelly 83d902a780
Fix JavaScript dependencies in bundles. (#4215)
Fixes #4602

We turned off `allowJs` by default, to keep the compiler from grabbing
a bunch of files that it wouldn't actually do anything useful with.  On
the other hand, this caused problems with bundles, where the compiler
needs to gather all the dependencies, including JavaScript ones.  This
fixes this so that when we are bundling, we analyse JavaScript imports
in the compiler.
2020-03-02 22:18:27 +01:00
João Souto 809019dc6e
Port Complex Permissions Tests to Rust (#4200) 2020-03-01 19:51:54 -05:00
Nayeem Rahman 1f9d158bdc
refactor(cli/js): Replace constructError() with getErrorClass() (#4189)
Flattens dispatch error handling to produce one less useless stack frame on op errors.
2020-02-29 19:04:10 +01:00
Bartek Iwańczuk a13b0e2727
rewrite permission revoke test as integration test (#4164) 2020-02-28 15:47:54 +01:00
Kevin (Kun) "Kassimo" Qian 7255cc9bc0
Support TypeScript eval through deno eval -T flag (#4141) 2020-02-28 09:17:56 -05:00
Ryan Dahl 973dbd1ba1
Return non-zero exit code on malformed stdin fmt (#4163) 2020-02-27 15:39:41 -05:00
Kitson Kelly 1d26da6a47
feat: Support types compiler option in compiler APIs (#4155)
Handles `types` in the compiler APIs to make it easier to supply
external type libraries.
2020-02-27 11:27:00 -05:00
Kitson Kelly 671f0b83be
Bundles can be sync or async based on top level await (#4124)
Previously, bundles always utilised top level await, even if the bundled
modules didn't require top level await.  Now, analysis of the bundle is
done and if none of the bundled modules are asynchronously executed,
then the bundle as a whole will be synchronously executed.

Fixes #4055
Fixes #4123
2020-02-26 17:59:33 +01:00
Ryan Dahl 9a8d6fbd98
DenoFlags -> Flags (#4136) 2020-02-26 11:52:15 +01:00
Kevin (Kun) "Kassimo" Qian 5946808f66
tty: Deno.setRaw(rid, mode) to turn on/off raw mode (#3958) 2020-02-26 01:01:24 -05:00
João Souto e53064c4f2
Port permission_prompt_tests to Rust (#4129) 2020-02-25 15:36:35 -05:00
Kitson Kelly be787d09d5
upgrade: TypeScript 3.8 (#4100) 2020-02-25 15:33:19 -05:00
Nayeem Rahman 14e7e1e3af
fix: Resolve makeTemp* paths from CWD (#4104) 2020-02-25 09:23:23 -05:00
Kitson Kelly 805992b14a
Fix issues with JavaScript importing JavaScript. (#4120)
Fixes #3852
Fixes #4117
2020-02-25 03:32:43 -05:00
João Souto ac933dd1b8
port tools/repl_test.py to Rust (#4096)
ref #2988
2020-02-24 17:49:40 -05:00
Suguru Motegi 79c6e052ed
fix: createSecKey logic (#4063) 2020-02-24 16:37:15 -05:00
EnokMan 14129b6c8f
feat: support brotli compression for fetch API (#4082) 2020-02-23 09:37:43 -05:00
Bartek Iwańczuk dd8a109481
refactor: remove unneeded ErrorKinds (#3936) 2020-02-21 10:36:13 -05:00
Bartek Iwańczuk d9efb8c02a
fix: add io ops to worker to fix fetch (#4054) 2020-02-21 10:35:41 -05:00
Kitson Kelly 6431622a6d
fix: mis-detecting imports on JavaScript when there is no checkJs (#4040)
This PR fixes an issue where we recursively analysed imports on plain JS files
in the compiler irrespective of "checkJs" being true. This caused problems
where when analysing the imports of those files, we would mistake some
import like structures (AMD/CommonJS) as dependencies and try to resolve
the "modules" even though the compiler would not actually look at those files.
2020-02-19 22:58:05 -05:00
Kitson Kelly 0e579ee9dc
fix: emit when bundle contains single module (#4042)
Fixes #4031

When a bundle contains a single module, we were incorrectly determining
the module name, resulting in a non-functional bundle.  This PR corrects
that determination.
2020-02-19 22:35:21 -05:00
Maximilien Mellen 90125566bb
Enable TS strict mode by default (#3899)
Fixes #3324 

Co-authored-by: Kitson Kelly <me@kitsonkelly.com>
2020-02-19 15:36:18 -05:00
Bartek Iwańczuk 852823fa50
refactor: rewrite HTTP cache for file fetcher (#4030) 2020-02-19 08:17:13 -05:00
Kitson Kelly 046bbb2691
Support loading additional TS lib files (#3863)
Fixes #3726

This PR provides support for referencing other lib files (like lib.dom.d.ts that are not
used by default in Deno.
2020-02-19 00:34:11 -05:00
geoFlux 2e7d449623
feat: add --cert flag for http client (#3972) 2020-02-17 11:59:51 -05:00
Kitson Kelly 98e585a284
Fix issue with detecting AMD like imports (#4009) 2020-02-16 11:11:44 +01:00
Ryan Dahl 9325744a94
Clean up fmt flags and path handling (#3988) 2020-02-13 16:02:18 -05:00
Kitson Kelly 6bd846a780
Improvements to bundling. (#3965)
Moves to using a minimal System loader for bundles generated by Deno.
TypeScript in 3.8 will be able to output TLA for modules, and the loader
is written to take advantage of that as soon as we update Deno to TS
3.8.

System also allows us to support `import.meta` and provide more ESM
aligned assignment of exports, as well as there is better handling of
circular imports.

The loader is also very terse versus to try to save overhead.

Also, fixed an issue where abstract classes were not being re-exported.

Fixes #2553
Fixes #3559
Fixes #3751
Fixes #3825
Refs #3301
2020-02-12 16:41:51 -05:00
Nayeem Rahman 701ce9b334
refactor: Use PathBuf for paths in flag parsing and whitelists (#3955)
* Use PathBuf for DenoSubcommand::Bundle's out_file
* Use PathBuf for DenoSubcommand::Format's files
* Use PathBuf for DenoSubcommand::Install's dir
* Use PathBuf for read/write whitelists
2020-02-11 10:29:36 +01:00
Bartek Iwańczuk 79b3bc05d6
workers: basic event loop (#3828)
* establish basic event loop for workers
* make "self.close()" inside worker
* remove "runWorkerMessageLoop() - instead manually call global function 
  in Rust when message arrives. This is done in preparation for structured clone
* refactor "WorkerChannel" and use distinct structs for internal 
  and external channels;  "WorkerChannelsInternal" and "WorkerHandle"
* move "State.worker_channels_internal" to "Worker.internal_channels"
* add "WorkerEvent" enum for child->host communication; 
  currently "Message(Buf)" and  "Error(ErrBox)" variants are supported
* add tests for nested workers
* add tests for worker throwing error on startup
2020-02-11 10:04:59 +01:00
Kevin (Kun) "Kassimo" Qian 5066018412
fmt: deno fmt - formats stdin and print to stdout (#3920) 2020-02-09 11:19:05 +01:00
Kevin (Kun) "Kassimo" Qian 619a24390f
install: add --force flag and remove yes/no prompt (#3917) 2020-02-08 09:49:55 +01:00
Ryan Dahl 99186dbaa2
Remove conditionals from installer (#3909) 2020-02-07 09:31:19 +01:00
Ryan Dahl 5e8581ff4b
fix 015_duplicate_parallel_import (#3904) 2020-02-06 21:24:51 -05:00
Ryan Dahl ed680552a2
fix: basic web worker message passing (#3893)
Removes OP_HOST_GET_WORKER_LOADED, OP_HOST_POLL_WORKER, 
OP_HOST_RESUME_WORKER and ready/messageBuffer in cli/js/workers.ts.
2020-02-05 17:16:07 -05:00
Luka Hartwig 7d115a2a65
refactor: port fetch test to rust (#3887) 2020-02-04 17:42:07 -05:00
Bartek Iwańczuk 184be99f5b
refactor: CLI subcommands and argv (#3886) 2020-02-04 20:24:33 +01:00
Tilman Roeder 2ab49a80a6
Do not encode files loaded from network as utf8 (#3856) 2020-02-04 11:27:50 -05:00
Bartek Iwańczuk 70eccff7f1
reenable some tests (#3882) 2020-02-04 09:10:46 -05:00
Ryan Dahl 161cf7cdfd
refactor: Use Tokio's single-threaded runtime (#3844)
This change simplifies how we execute V8. Previously V8 Isolates jumped
around threads every time they were woken up. This was overly complex and
potentially hurting performance in a myriad ways. Now isolates run on
their own dedicated thread and never move.

- blocking_json spawns a thread and does not use a thread pool
- op_host_poll_worker and op_host_resume_worker are non-operational
- removes Worker::get_message and Worker::post_message
- ThreadSafeState::workers table contains WorkerChannel entries instead
  of actual Worker instances.
- MainWorker and CompilerWorker are no longer Futures.
- The multi-threaded version of deno_core_http_bench was removed.
- AyncOps no longer need to be Send + Sync

This PR is very large and several tests were disabled to speed
integration:
- installer_test_local_module_run
- installer_test_remote_module_run
- _015_duplicate_parallel_import
- _026_workers
2020-02-03 18:08:44 -05:00
Luka Hartwig f168597b7a
Remove //tests symlink (#3849) 2020-02-02 16:55:22 -05:00
Tim Ermilov 2cd3994902
Add support for multiple files in fetch command (#3845) 2020-01-31 16:07:37 -05:00
Bartek Iwańczuk e1697421e2
chore: remove std/installer, port installer tests to Rust (#3843) 2020-01-31 17:34:50 +01:00
Ryan Dahl 2338e7679c
Remove --current-thread flag (#3830)
This flag was added to evaluate performance relative to tokio's threaded
runtime. Although it's faster in the HTTP benchmark, it's clear the runtime
is not the only perf problem.

Removing this flag will simplify further refactors, in particular
adopting the #[tokio::main] macro. This will be done in a follow up.

Ultimately we expect to move to the current thread runtime with Isolates
pinned to specific threads, but that will be a much larger refactor. The
--current-thread just complicates that effort.
2020-01-30 10:49:33 -05:00
Bartek Iwańczuk 73a3cc21d0
feat: dprint formatter (#3820)
* rewrite fmt_test in Rust, remove tools/fmt_test.py
* remove //std/prettier
2020-01-29 21:16:48 -05:00
Bartek Iwańczuk 161adfc51b
workers: proper TS libs, more spec-compliant APIs (#3812)
* split lib.deno_main.d.ts into:
  - lib.deno.shared_globals.d.ts
  - lib.deno.window.d.ts
  - lib.deno.worker.d.ts
* remove no longer used libs:
  - lib.deno_main.d.ts
  - lib.deno_worker.d.ts
* change module loading to use proper TS library for compilation
* align to Worker API spec:
  - Worker.terminate()
  - self.close()
  - self.name
2020-01-29 18:54:23 +01:00
Bartek Iwańczuk f32c31a0eb dx: descriptive permission errors (#3808)
Before:
```
▶ target/debug/deno https://deno.land/std/examples/echo_server.ts
error: Uncaught PermissionDenied: run again with the --allow-net flag
► $deno$/dispatch_json.ts:40:11
    at DenoError ($deno$/errors.ts:20:5)
    at unwrapResponse ($deno$/dispatch_json.ts:40:11)
    at sendSync ($deno$/dispatch_json.ts:67:10)
    at listen ($deno$/net.ts:170:15)
    at https://deno.land/std/examples/echo_server.ts:4:23
```

```
▶ target/debug/deno --allow-read=/usr https://deno.land/std/examples/cat.ts /etc/passwd
error: Uncaught PermissionDenied: run again with the --allow-read flag
► $deno$/dispatch_json.ts:40:11
    at DenoError ($deno$/errors.ts:20:5)
    at unwrapResponse ($deno$/dispatch_json.ts:40:11)
    at sendAsync ($deno$/dispatch_json.ts:91:10)
```

After:
```
▶ target/debug/deno https://deno.land/std/examples/echo_server.ts
error: Uncaught PermissionDenied: network access to "0.0.0.0:8080", run again with the --allow-net flag
► $deno$/dispatch_json.ts:40:11
    at DenoError ($deno$/errors.ts:20:5)
    at unwrapResponse ($deno$/dispatch_json.ts:40:11)
    at sendSync ($deno$/dispatch_json.ts:67:10)
    at listen ($deno$/net.ts:170:15)
    at https://deno.land/std/examples/echo_server.ts:4:23
```

```
▶ target/debug/deno --allow-read=/usr https://deno.land/std/examples/cat.ts /etc/passwd
error: Uncaught PermissionDenied: read access to "/etc/passwd", run again with the --allow-read flag
► $deno$/dispatch_json.ts:40:11
    at DenoError ($deno$/errors.ts:20:5)
    at unwrapResponse ($deno$/dispatch_json.ts:40:11)
    at sendAsync ($deno$/dispatch_json.ts:91:10)
```
2020-01-27 21:13:17 -05:00
Kitson Kelly f604becaba Improve support of type definitions (#3755) 2020-01-26 13:59:41 -05:00
Kevin (Kun) "Kassimo" Qian ec44be0760 lock: support lock-write for fetch command (#3787) 2020-01-26 13:43:59 -05:00
Ben Noordhuis 97ed0c954d feat: make eval support --v8-flags=... (#3797)
Closes #3796
2020-01-26 09:49:34 -05:00