Commit graph

14 commits

Author SHA1 Message Date
Bartek Iwańczuk 9d63772fe5
refactor: rewrite TS dependency analysis in Rust (#5029)
This commit completely overhauls how module analysis is 
performed in TS compiler by moving the logic to Rust.

In the current setup module analysis is performed using 
"ts.preProcessFile" API in a special TS compiler worker 
running on a separate thread.

"ts.preProcessFile" allowed us to build a lot of functionality
in CLI including X-TypeScript-Types header support 
and @deno-types directive support. Unfortunately at the 
same time complexity of the ops required to perform 
supporting tasks exploded and caused some hidden 
permission escapes.

This PR introduces "ModuleGraphLoader" which can parse
source and load recursively all dependent source files; as 
well as declaration files. All dependencies used in TS 
compiler and now fetched and collected upfront in Rust 
before spinning up TS compiler.

To achieve feature parity with existing APIs this commit 
includes a lot of changes:

* add "ModuleGraphLoader"
  - can fetch local and remote sources
  - parses source code using SWC and extracts imports, exports, file references, special 
     headers
  - this struct inherited all of the hidden complexity and cruft from TS version and requires 
     several follow up PRs
* rewrite cli/tsc.rs to perform module analysis upfront and send all required source code to 
  TS worker in one message
* remove op_resolve_modules and op_fetch_source_files from cli/ops/compiler.rs
* run TS worker on the same thread
2020-05-18 12:59:29 +02:00
Bartek Iwańczuk 2ecdbb62ae
refactor: merge TS compiler into single file (#5091) 2020-05-06 00:19:18 +02:00
Bartek Iwańczuk 9cd7d59840
fix(cli): fix paths in internal stack traces (#5093)
This commit updates "deno_typescript" crate to properly map
bundle entrypoint file to internal specifier.

All import specifiers were remapped from "file:///a/b/c.ts" to
"$deno$/a/b/c.ts", but that was not the case for entrypoint file
"main.ts" and "compiler.ts".

Because of that internal stack traces were inconsistent; showing
"file:///some/random/path/on/ci/machine.ts" URL in frames that
originate from "main.ts" or "compiler.ts" and "$deno$/file.ts"
for all other imports.
2020-05-05 23:13:04 +02:00
Nayeem Rahman ef6ee25e09
refactor(cli/fmt_errors): Improve source line formatting (#4832) 2020-04-20 15:39:02 -04:00
Nayeem Rahman 2b362bef85
refactor(cli/fmt_errors): Format stack frames in prepareStackTrace() (#4706) 2020-04-11 02:08:11 -04:00
Nayeem Rahman 8b4508338b
fix(core/js_error): Get frame data from prepareStackTrace() (#4690)
Fixes: #2703
Fixes: #2710
Closes: #4153
Closes: #4232

Co-authored-by: Kevin (Kun) Kassimo Qian <kevinkassimo@gmail.com>
2020-04-10 18:26:52 +02:00
Bartek Iwańczuk 99a0c6df79
reorg: cli/js/compiler/, move more API to cli/js/web/ (#4310)
- moves compiler implementation to "cli/js/compiler/" directory
- moves more APIs to "cli/js/web":
    * "console.ts"
    * "console_table.ts"
    * "performance.ts"
    * "timers.ts"
    * "workers.ts"
- removes some dead code from "cli/js/"
2020-03-11 10:53:06 +01:00
Bartek Iwańczuk 1b6f831875
reorg: move JS ops implementations to cli/js/ops/, part 1 (#4264)
Following JS ops were moved to separate files in cli/js/ops directory:
- compiler
- dispatch_json
- dispatch_minimal
- errors
- fetch
- fs_events
- os
- random
- repl
- resources
- runtime_compiler
- runtime
- tty
2020-03-08 13:09:22 +01: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 dd8a109481
refactor: remove unneeded ErrorKinds (#3936) 2020-02-21 10:36:13 -05:00
Kitson Kelly d325566a7e Runtime Compiler API (#3442)
Also restructures the compiler TypeScript files to make them easier to
manage and eventually integrate deno_typescript fully.
2020-01-08 09:17:44 -05:00
Bartek Iwańczuk 9712e0c315 better error messages for 'relative import path not prefixed with / or ./ or ../' (#3405) 2019-11-26 09:14:04 -08:00
Kitson Kelly d9ff4eccb5 Async compiler processing (#3043)
Basically this does pre-processing of TypeScript files and gathers all the
dependencies asynchronously. Only then after all the dependencies are gathered,
does it do a compile, which at that point all the dependencies are cached in
memory in the compiler, so with the exception of the hard coded assets, there
are no ops during the compilation.

Because op_fetch_source_files is now handled asynchronously in the runtime, we
can eliminate the tokio_util::block_on() which was causing the increase in
threads. Benchmarking on my machine has shown about a 5% improvement in speed
when dealing with compiling TypeScript. Still a long way to go, but an
improvement.

In theory the module name resolution and the fetching of the source files could
be broken out as two different ops. This would prevent situations of sending the
full source file all the time when actually the module is the same module
referenced by multiple modules, but that could be done subsequently to this.
2019-10-03 07:23:29 -04:00
Ryan Dahl 9cfdc60a23
Move integration tests to //cli/tests/ (#2964)
This ensures the deno executable is properly created before running the integration tests.

Also allows deno_cli to be used as a lib. Docs are now properly generated: https://docs.rs/deno_cli/0.18.4/deno_cli/

Towards #2933
Prep for #2955
2019-09-16 21:05:14 -04:00
Renamed from tests/error_011_bad_module_specifier.ts.out (Browse further)