summaryrefslogtreecommitdiff
path: root/cli/js/compiler.ts
AgeCommit message (Collapse)Author
2020-07-19Port internal TS code to JS (#6793)Bartek Iwańczuk
Co-authored-by: Ryan Dahl <ry@tinyclouds.org>
2020-07-14Use dprint for internal formatting (#6682)David Sherret
2020-07-08feat: add --no-check option (#6456)Kitson Kelly
This commit adds a "--no-check" option to following subcommands: - "deno cache" - "deno info" - "deno run" - "deno test" The "--no-check" options allows to skip type checking step and instead directly transpiles TS sources to JS sources. This solution uses `ts.transpileModule()` API and is just an interim solution before implementing it fully in Rust.
2020-07-06clean up code in cli/js (#6611)Stanislav
2020-07-05chore: improve type safety of cli/js/compiler (#6647)Kitson Kelly
2020-06-25Restore stats for incremental compile (#6474)Kitson Kelly
2020-06-24Incremental compilation for TypeScript (#6428)Bartek Iwańczuk
This commit adds incremental compilation capabilities to internal TS compiler. Instead of using "ts.createProgram()" API for compilation step (during deno startup), "ts.createIncrementalProgram()" API is used instead. Thanks to TS' ".tsbuildinfo" file that already stores all necessary metadata for compilation I was able to remove our own invention that is ".graph" file. ".tsbuildinfo" file is stored alongside compiled source and is used to cache-bust outdated dependencies, facilitated by the "version" field. The value for "version" field is computed in Rust during loading of module graph and is basically a hash of the file contents. Please keep in mind that incremental compilation is only used for initial compilation (or dynamic imports compilation) - bundling and runtime compiler APIs haven't been changed at all. Due to problems with source map I changed compilation settings to inline source map (inlineSourceMap instead of sourceMap).
2020-06-24Add ability to output compiler performance information (#6434)Kitson Kelly
2020-06-19refactor(compiler): split code paths for compile and bundle (#6304)Bartek Iwańczuk
* refactor "compile" and "runtimeCompile" in "compiler.ts" and factor out separate methods for "compile" and "bundle" operations * remove noisy debug output from "compiler.ts" * provide "Serialize" implementations for enums in "msg.rs" * rename "analyze_dependencies_and_references" to "pre_process_file" and move it to "tsc.rs" * refactor ModuleGraph to use more concrete types and properly annotate locations where errors occur * remove dead code from "file_fetcher.rs" - "SourceFile.types_url" is no longer needed, as type reference parsing is done in "ModuleGraph" * remove unneeded field "source_path" from ".meta" files stored for compiled source file (towards #6080)
2020-06-18Deno.bundle supports targets < ES2017 (#6346)Ryan Dahl
This commit provides a "system_loader_es5.js" bundle loader which will be added to the bundle when the target is < ES2017, which is the minimum target syntax required for "system_loader.js". Supports #5913 (via Deno.bundle()) with a couple caveats: * Allowing "deno bundle" to take a different target is not supported, as we specifically ignore "target" when passed in a TypeScript config file. This is because deno bundle is really intended to generate bundles that work in Deno. It is an unintentional side effect that some bundles are loadable in browsers. * While a target of "es3" will be accepted, the module loader will still only be compatible with ES5 or later. Realistically no one should be expecting bundles generated by Deno to be used on IE8 and prior, and there is just too much "baggage" to support that at this point. This is a minor variation of 75bb9d, which exposed some sort of internal V8 bug. Ref #6358 This is 100% authored by Kitson Kelly. Github might change the author when landing so I'm leaving this in: Co-authored-by: Kitson Kelly <me@kitsonkelly.com>
2020-06-17Revert "Deno.bundle supports targets < ES2017. (#6328)" (#6342)Bartek Iwańczuk
This reverts commit 75bb9dbdfc7f8b4e8d17978808ae575e61843aef.
2020-06-17Deno.bundle supports targets < ES2017. (#6328)Kitson Kelly
This commit provides a "system_loader_es5.js" bundle loader which will be added to the bundle when the target is < ES2017, which is the minimum target syntax required for "system_loader.js". Supports #5913 (via Deno.bundle()) with a couple caveats: * Allowing "deno bundle" to take a different target is not supported, as we specifically ignore "target" when passed in a TypeScript config file. This is because deno bundle is really intended to generate bundles that work in Deno. It is an unintentional side effect that some bundles are loadable in browsers. * While a target of "es3" will be accepted, the module loader will still only be compatible with ES5 or later. Realistically no one should be expecting bundles generated by Deno to be used on IE8 and prior, and there is just too much "baggage" to support that at this point.
2020-06-10fix: several regressions in TS compiler (#6177)Bartek Iwańczuk
This commit fixes several regressions in TS compiler: * double compilation of same module during same process run * compilation of JavaScript entry point with non-JS imports * unexpected skip of emit during compilation Additional checks were added to ensure "allowJs" setting is used in TS compiler if JavaScript has non-JS dependencies.
2020-05-22fix: redirects handling in module analysis (#5726)Bartek Iwańczuk
This commit fixes a bug introduced in #5029 that caused bad handling of redirects during module analysis. Also ensured that duplicate modules are not downloaded.
2020-05-20refactor: reorganize TS compiler (#5603)Bartek Iwańczuk
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-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-06refactor(ts): make processImports logic more verbose (#5089)Bartek Iwańczuk
2020-05-06refactor: merge TS compiler into single file (#5091)Bartek Iwańczuk
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-04Make it so ts compiler doesn't call cwd op (#5070)Ryan Dahl
Removes duplicate implementation of the module resolution algorithm
2020-04-30Unstable methods should not appear in runtime or d.ts (#4957)Luca Casonato
Co-authored-by: Kitson Kelly <me@kitsonkelly.com>
2020-04-25remove bootstrap methods from global scope after bootstrapping (#4869)Bartek Iwańczuk
2020-04-16feat: support Deno namespace in Worker API (#4784)Bartek Iwańczuk
2020-03-28Update to Prettier 2 and use ES Private Fields (#4498)Kitson Kelly
2020-03-20Add require-await lint rule (#4401)Samrith Shankar
2020-03-15Remove Object.prototype.__proto__ (#4341)Kitson Kelly
2020-03-13Remove doc strings from cli/js TS files (#4329)crowlKats
Co-authored-by: Ryan Dahl <ry@tinyclouds.org>
2020-03-11reorg: cli/js/compiler/, move more API to cli/js/web/ (#4310)Bartek Iwańczuk
- 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-05move Web APIs to cli/js/web/Bartek Iwańczuk
2020-03-05refactor: cleanup compiler runtimes (#4230)Bartek Iwańczuk
- Cleanup "tsCompilerOnMessage" by factoring out separate methods for each request type: * "compile" * "runtimeCompile" * "runtimeTranspile" - Simplify control flow of compiler workers by a) no longer calling "close()" in worker runtime after a single message; b) explicitly shutting down worker from host after a single message Co-authored-by: Ryan Dahl <ry@tinyclouds.org>
2020-03-02Fix JavaScript dependencies in bundles. (#4215)Kitson Kelly
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-02-27feat: Support types compiler option in compiler APIs (#4155)Kitson Kelly
Handles `types` in the compiler APIs to make it easier to supply external type libraries.
2020-02-19fix: mis-detecting imports on JavaScript when there is no checkJs (#4040)Kitson Kelly
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-11workers: basic event loop (#3828)Bartek Iwańczuk
* 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-07Improve support for diagnostics from runtime compiler APIs (#3911)Kitson Kelly
- Exports diagnostic items from `diagnostics.ts` which are missing at runtime. - Returns an array of diagnostics, instead of an object with a property of `items`. This is because of the way Rust deals with certain structures, and shouldn't be exposed in the APIs.
2020-01-29workers: proper TS libs, more spec-compliant APIs (#3812)Bartek Iwańczuk
* 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-27refactor: isomorphic snapshot for CLI (#3728)Bartek Iwańczuk
2020-01-24Break out runtime lib to main and worker (#3771)Kitson Kelly
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
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: Rename JS entry functions (#3732)Bartek Iwańczuk
2020-01-21refactor: split worker and worker host logic (#3722)Bartek Iwańczuk
* split ops/worker.rs into ops/worker_host.rs and ops/web_worker.rs * refactor js/workers.ts and factor out js/worker_main.ts - entry point for WebWorker runtime * BREAKING CHANGE: remove support for blob: URL in Worker * BREAKING CHANGE: remove Deno namespace support and noDenoNamespace option in Worker constructor * introduce WebWorker struct which is a stripped down version of cli::Worker
2020-01-20Use globalThis to reference global scope (#3719)Kitson Kelly
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2020-01-17Fix compile and bundle api types (#3703)Klaus Hvam
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-02Happy new year! (#3578)Ry Dahl
2019-11-25better error message for missing module (#3402)Bartek Iwańczuk
2019-11-20feat: Support named exports on bundles. (#3352)Kitson Kelly