summaryrefslogtreecommitdiff
path: root/cli/ops/compiler.rs
AgeCommit message (Collapse)Author
2020-09-26refactor: use JsRuntime to implement TSC (#7691)Bartek Iwańczuk
This commits removes "CompilerWorker" in favor of using "JsRuntime". "cli/ops/compiler.rs" has been removed in favor of inline registration of ops in "cli/tsc.rs"
2020-09-21refactor: use futures and serde_json from deno_core (#7614)Bartek Iwańczuk
2020-09-10Use gotham-like state for ops (#7385)Ryan Dahl
Provides a concrete state type that can be dynamically added. This is necessary for op crates. * renames BasicState to OpState * async ops take `Rc<RefCell<OpState>>` * sync ops take `&mut OpState` * removes `OpRegistry`, `OpRouter` traits * `get_error_class_fn` moved to OpState * ResourceTable moved to OpState
2020-09-06Move JSON ops to deno_core (#7336)Bert Belder
2020-08-26refactor: remove OpError, use ErrBox everywhere (#7187)Bert Belder
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2020-08-19Make Rc/Arc wrapper around State/GlobalState visible (#7104)Bert Belder
2020-08-12Undo JsonOpDispatcher and OpDispatcher traits (#7023)Ryan Dahl
This reverts commit f83d672ffad7afb1473bd4f9b9c645539064c620. This reverts commit d51972377c1325076704d9faec2eee6f0e024496.
2020-07-23refactor: remove more compiler runtime code (#6841)Bartek Iwańczuk
2020-07-20Remove deno_typescript (#6813)Ryan Dahl
2020-05-18refactor: rewrite TS dependency analysis in Rust (#5029)Bartek Iwańczuk
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-11refactor: check permissions in SourceFileFetcher (#5011)Bartek Iwańczuk
This PR hot-fixes permission escapes in dynamic imports, workers and runtime compiler APIs. "permissions" parameter was added to public APIs of SourceFileFetcher and appropriate permission checks are performed during loading of local and remote files.
2020-05-07BREAKING: Remove support for .wasm imports (#5135)Bartek Iwańczuk
Importing .wasm files is non-standardized therefore deciding to support current functionality past 1.0 release is risky. Besides that .wasm import posed many challenges in our codebase due to complex interactions with TS compiler which spawned thread for each encountered .wasm import. This commit removes: - cli/compilers/wasm.rs - cli/compilers/wasm_wrap.js - two integration tests related to .wasm imports
2020-05-05refactor(ts): remove op_cache (#5071)Bartek Iwańczuk
This PR removes op_cache and refactors how Deno interacts with TS compiler. Ultimate goal is to completely sandbox TS compiler worker; it should operate on simple request -> response basis. With this commit TS compiler no longer caches compiled sources as they are generated but rather collects all sources and sends them back to Rust when compilation is done. Additionally "Diagnostic" and its children got refactored to use "Deserialize" trait instead of manually implementing JSON deserialization.
2020-05-02BREAKING: disallow static import of local modules from remote modules (#5050)Bartek Iwańczuk
This commit changes module loading logic to disallow statically import local module (file:// scheme) from remote modules (http://, https:// schemes).
2020-05-02BREAKING: remove support for JSON imports (#5037)Bartek Iwańczuk
This commit removes support for importing JSON files as modules. This change is dictated by security; browsers rolled back on this support as well.
2020-04-23Rename deno_core::Isolate to deno_core::CoreIsolate (#4851)Ryan Dahl
2020-04-15remove calls to futures::executor::block_on (#4760)Bartek Iwańczuk
2020-04-10Replace panic with invalid_utf8 OpError (#4704)gewoonwoutje
Co-authored-by: Wout Elstgeest <w.elstgeest@inepro.com>
2020-03-18Provide compiled JSON to TypeScript compiler. (#4404)Kitson Kelly
Fixes #4101 Previously, we would just provide the raw JSON to the TypeScript compiler worker, but TypeScript does not transform JSON. This caused a problem when emitting a bundle, that the JSON would just be "inlined" into the output, instead of being transformed into a module. This fixes this problem by providing the compiled JSON to the TypeScript compiler, so TypeScript just sees JSON as a "normal" TypeScript module.
2020-03-02refactor: rename structures related to Modules (#4217)Bartek Iwańczuk
* rename structures related to ES Modules; add "Modules" prefix * remove unneeded Unpin trait requirement for "ModuleLoader"
2020-02-25Remove _async from method names since _sync are gone (#4128)Ryan Dahl
2020-02-25Clean up how we use opIds (#4118)Ryan Dahl
2020-02-23refactor: use OpError instead of ErrBox for errors in ops (#4058)Bartek Iwańczuk
To better reflect changes in error types in JS from #3662 this PR changes default error type used in ops from "ErrBox" to "OpError". "OpError" is a type that can be sent over to JSON; it has all information needed to construct error in JavaScript. That made "GetErrorKind" trait useless and so it was removed altogether. To provide compatibility with previous use of "ErrBox" an implementation of "From<ErrBox> for OpError" was added, however, it is an escape hatch and ops implementors should strive to use "OpError" directly.
2020-02-19refactor: rewrite file_fetcher to use async fns, lift blocking call (#4037)Bartek Iwańczuk
2020-02-19Support loading additional TS lib files (#3863)Kitson Kelly
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-08refactor: rename ThreadSafeState, use RefCell for mutable state (#3931)Bartek Iwańczuk
* rename ThreadSafeState to State * State stores InnerState wrapped in Rc and RefCell
2020-01-26Improve support of type definitions (#3755)Kitson Kelly
2020-01-25refactor: Modules and Loader trait (#3791)Bartek Iwańczuk
* move is_dyn_import argument from Loader::resolve to Loader::load - it was always kind of strange that resolve() checks permissions. * change argument type from &str to &ModuleSpecifier where applicable
2020-01-24s/PinnedBuf/ZeroCopyBuf (#3782)Ryan Dahl
2020-01-22Reland "Create an old program to be used in snapshot." (#3747)Bartek Iwańczuk
* read CLI assets from disk during snapshotting
2020-01-21Revert "Create an old program to be used in snapshot. (#3644)"Ry Dahl
Ref #3712. This change allowed the deno_typescript crate to reference cli/js/lib.deno_runtime.d.ts which breaks "cargo package". We intend to reintroduce a revised version of this patch later once "cargo package" is working and tested. This reverts commit 737ab94ea1bdf65eeef323ea37e84bcf430fb92c.
2020-01-21refactor: split cli::Worker (#3735)Bartek Iwańczuk
* cli::Worker is base struct to create specialized workers * add MainWorker * add CompilerWorker * refactor WebWorker to use Worker
2020-01-12Create an old program to be used in snapshot. (#3644)Kitson Kelly
2020-01-08Runtime Compiler API (#3442)Kitson Kelly
Also restructures the compiler TypeScript files to make them easier to manage and eventually integrate deno_typescript fully.
2020-01-05Rename crates: 'deno' to 'deno_core' and 'deno_cli' to 'deno' (#3600)Ry Dahl
2020-01-04Use async at places, use &self instead of self: &Self (#3594)Gurwinder Singh
2020-01-02Happy new year! (#3578)Ry Dahl
2019-11-25better error message for missing module (#3402)Bartek Iwańczuk
2019-11-16Use futures 0.3 API (#3358)Bartek Iwańczuk
2019-11-14Loader: support .wasm imports (#3328)Kevin (Kun) "Kassimo" Qian
* loader: support .wasm imports * http_server: true * Support named exports * Clippy
2019-11-04Refactor Worker and ThreadSafeState (#3242)Bartek Iwańczuk
* Split ThreadSafeState into State and GlobalState. State is a "local" state belonging to "Worker" while "GlobalState" is state shared by whole program. * Update "Worker" and ops to use "GlobalState" where applicable * Move and refactor "WorkerChannels" resource
2019-10-11Add init methods for each op module (#3087)Ryan Dahl
2019-10-04Merge deno_cli_snapshots into deno_cli (#3064)Ryan Dahl
2019-10-03Async compiler processing (#3043)Kitson Kelly
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-09-15Make deno_cli installable via crates.io (#2946)Ryan Dahl
- Fixes cargo publish on deno_typescript, deno_cli_snapshots, and deno_cli. - Combines cli_snapshots and js into one directory. - Extracts TS version at compile time rather than runtime - Bumps version awkwardly - it was necessary to test end-to-end publishing. Sorry. - Adds git submodule deno_typescript/typescript
2019-09-14feat: parallelize downloads from TS compiler (#2949)Bartek Iwańczuk
2019-08-30Remove ts_library_builder, maintain lib.deno_runtime.d.ts by hand (#2827)Ryan Dahl
2019-08-26bring back json ops (#2815)Bartek Iwańczuk
2019-08-24Revert json ops (#2814)Ryan Dahl
* Revert "port more ops to JSON (#2809)" This reverts commit 137f33733d365026903d40e7cde6e34ac6c36dcf. * Revert "port ops to JSON: compiler, errors, fetch, files (#2804)" This reverts commit 79f82cf10ed1dbf91346994250d7311a4d74377a. * Revert "Port rest of os ops to JSON (#2802)" This reverts commit 5b2baa5c990fbeae747e952c5dcd7a5369e950b1.
2019-08-24port ops to JSON: compiler, errors, fetch, files (#2804)Bartek Iwańczuk