Commit graph

342 commits

Author SHA1 Message Date
Tobias Koppers
c7ff4150c8 fix consistency issues (vercel/turbo#224)
There are a bunch or problems with invalidations:

* The fs impl watches path case-insenstive. This means two paths might conflict when on a case-sensitive filesystem. It uses an array of Invalidators now
* Move the next-dev bootstrapping logic out of the run_once scope (which is not updated when invalidations occur). Instead it's executed inside the request handling resp. update stream where changes can be handled.
* `TransientValue` was not an Value type actually. This fixes that.
* Adds a new `TransientInstance` wrapper to pass transient by reference.
* `strongly_consistent` was broken when using nested TaskScopes. This fixes that.
2022-08-16 13:12:09 +00:00
Tobias Koppers
eab61f3c65 add basic next pages support (vercel/turbo#223)
Server Rendering:

* This adds an additional ContentSource to next-dev which takes care of handling the `pages` directory.
* The content source creates a ServerRenderedAsset from each file in the `src/pages` or `pages` directory and a AssetGraphContentSource for that.
* The ServerRenderedAsset will reference an underlying asset for the node.js context which will be passed to the node executable for rendering. It uses a WrapperAsset to add additional communication logic.

Client Transition:

* When annotating `import`s with `transition: "next-client"` the NextClientTransition is used
* This transition changes the environment to browser
* It wraps the referenced asset with a next-hyrdation wrapper asset
* It leaves a little module in the previous context which exports a list of URLs for chunks needed.
* The NextClientTransition takes a client_chunking_context as argument which specifies how the client code is chunked.
2022-08-15 17:26:37 +00:00
Will Binns-Smith
935e46f995 next-dev test runner: ask os for free port (vercel/turbo#238)
These integration tests have been flaky, failing when a "free" port turns out to be in use. Since nextest parallelizes test runs and portpicker guesses and checks free ports [0], I'm guessing that there's a collision occurring. 

Instead, ask the operating system for a free port by binding to port 0 and read the port back from the resulting address.

Test Plan: Tried local runs with nextest, but those succeeded before as well. I'll probably retry things on CI a few times.

[0] 912f913ac3/src/lib.rs (L53)
2022-08-12 21:21:21 +00:00
Will Binns-Smith
c2fb81dd37 next-dev test runner: Ensure skipped tests fail (vercel/turbo#216)
This adds test runs for integration tests in `__skipped__` directories,
ensuring that they fail, otherwise they should probably be unskipped.

Test Plan: Temporarily moved a succeeding test into a `__skipped__`
directory and ensured that cargo test began failing that test.
2022-08-11 09:39:32 -07:00
Will Binns-Smith
4778270305 next-dev test runner: Check in and use webpack's chunk test cases (vercel/turbo#212)
This commits webpack's chunk tests (test/cases/chunks) and skips those
that do not pass yet.

Test Plan: `cargo test -p next-dev -- --nocapture` and verify the
non-skipped tests run.
2022-08-11 09:33:25 -07:00
Alex Kirszenberg
1d8b74c655 Introduce FileContent, Versioned, and refactor dev server updates (vercel/turbo#209)
This prepares the way for HMR (vercel/turbo#160) by letting us diff assets between
versions.

1. Add `Asset::versioned_content` which returns a `VersionedContentVc`.
2. `VersionedContent`s have a built-in versioning mechanism as they must implement `version() -> VersionVc`. `Version` is a trait, so `VersionVc` can contain a specific version implementation by asset type. This is particularly important because... 
3. A `VersionedContentVc` can be diffed with a `VersionVc` from the same underlying `VersionedContent` type with `content.update(from: version)`. This returns an `UpdateVc` which describes the steps necessary to update from one verson to the next. In the case of ES chunks, this will be a map of added, and modified module IDs, with their respective factories, and a set of deleted module IDs.
4. Implement diffing for ES chunks.
2022-08-11 08:03:38 +00:00
Will Binns-Smith
51c69f20f8 next-dev test runner: Implement manual debug mode (vercel/turbo#211)
This implements a manual debug mode for next-dev tests, enabled by
setting the environment variable TURBOPACK_DEBUG_BROWSER to any value.

It launches the test browser in non-headless mode and holds it open
~~indefinitely~~ until the user closes it, so it can be inspected.

Test Plan: `TURBOPACK_DEBUG_BROWSER=1 cargo test -p next-dev --
test_crates_next_dev_tests_integration_chunks_circular_correctness
--nocapture` and verify the browser is opened non-headless and is held
open
2022-08-10 10:14:01 +00:00
Alex Kirszenberg
1a5d175d8d Update toolchain to 2022-08-02 (vercel/turbo#215)
* Update toolchain to 2022-08-02

* Fix warnings
2022-08-09 19:38:05 +02:00
Will Binns-Smith
7bd5321b09 next-dev test runner (vercel/turbo#172)
This is a very early version of the next-dev test runner. I'm opening this early to get thoughts from folks re: the direction of the design and implementation.

Fixes vercel/turbo#204 

Currently it:
* Discovers integration test fixtures from the filesystem. Right now these are expected to be single files that get bundled and will eventually include assertions. This is powered by the test-generator crate, which allows us not to have to manually enumerate each case. We could consider using this for the node-file-trace tests as well.
* Starts the dev server on a free port and opens a headless browser to its root. The browser control is implemented with the https://crates.io/crates/chromiumoxide crate, which expects Chrome or Chromium to already be available.

Eventually it will:
* [x] Implement a minimal test environment loaded in the browser so that assertions can be run there from bundled code.
* [x] Report back the results of these assertions to rust, where we can pass/fail cargo tests with those results.

In the future it could:
* Possibly include snapshot-style tests to assert on transformed results. This could be in the form of fixture directories instead of files cc @jridgewell
* Support expressing special configuration of turbopack in a fixture, possibly as another file in the fixture directory.
* [x] ~Possibly support distributing tests to a pool of open browsers instead of opening and closing for each test.~

Test Plan: See next PRs
2022-08-09 16:20:30 +00:00
Tobias Koppers
659a5fd83d add issue reporting to next dev (vercel/turbo#208) 2022-08-08 07:39:52 +00:00
Leah
1277c36e35 refactor turbo-tasks-macros (vercel/turbo#198)
Changes attribute/argument parsing to the more usual `field = "value"` / `turbo_tasks(trace_ignore)`
2022-08-05 06:26:22 +00:00
Leah
5e4ba91c7c rename ModuleAsset (vercel/turbo#206) 2022-08-05 06:20:42 +00:00
Leah
71429b9beb simplify turbo_tasks::value (vercel/turbo#196)
Removes the trait arguments and registers them separately
2022-08-04 21:58:32 +00:00
Leah
64bb520332 add open-browser option (vercel/turbo#199)
Fixes https://github.com/vercel/turbo-tooling/issues/171
2022-08-04 21:58:19 +00:00
Tobias Koppers
796f605301 track processing path for issues (vercel/turbo#205)
allow to attach context at any point

show processing path in output

move cli issue display into separate crate
2022-08-04 21:14:09 +00:00
Leah
1d4821382b fix css layer import (vercel/turbo#195)
kdy1 fixes this upstream
2022-08-03 03:37:56 +00:00
Will Binns-Smith
01a7e41834 Extract server creation into own function and module (vercel/turbo#191)
* Extract server creation into fn

* Use builder pattern and anyhow context
2022-08-02 16:28:11 -07:00
Alex Kirszenberg
8fad8a6881 Custom debug implementation for Vcs (vercel/turbo#193)
This PR builds our own `Debug`-like derive-macro machinery for formatting structs, relying on `std::fmt::Formatter` for the actual formatting.

### Usage

A new `ValueDebug` trait is automatically implemented for all `#[turbo_tasks::value]`s, which has a single `.dbg()` method which resolves to a debug representation that can then be printed to the screen. `#[turbo_tasks::value_trait]` also implement the `.dbg()` method directly.

```rust
dbg!(any_vc.dbg().await?);
```

If you have a `#[turbo_tasks::value]` struct with a field that doesn't implement `Debug`, you'll want to declare that field as `#[debug_ignore]`. For instance:

```rust
#[turbo_tasks::value(ContentSource, serialization: none, eq: manual, cell: new, into: new)]
pub struct TurboTasksSource {
    #[debug_ignore]
    #[trace_ignore]
    pub turbo_tasks: Arc<TurboTasks<MemoryBackend>>,
}
```

### Why not use `Debug` directly?

We can't use `Debug` because our values are resolved asynchronously and can nest `Vc`s arbitrarily. I tried using `futures::executor::block_on` to resolve them synchronously in a `Debug` implementation but that causes deadlocks.
2022-08-02 17:36:48 +00:00
Tobias Koppers
12d720ff48 refactor lazy asset to lazy graph content source (vercel/turbo#186) 2022-08-01 07:53:09 +00:00
Tobias Koppers
41c2dfd2de introduce ContentSource as source for the dev server (vercel/turbo#185)
and potentially a next build in future
2022-08-01 07:02:53 +00:00
Tobias Koppers
52557b1c4d introduce an Environment and track that for the graph and Assets (vercel/turbo#167) 2022-07-27 22:33:14 +00:00
Will Binns-Smith
45b409393d Move browser opening to next-dev cli (vercel/turbo#169)
Cherry-picking this from my work on the next-dev test runner.

This moves browser opening from the turbopack-dev-server crate into the next-dev crate, which has the cli entrypoint that runs the dev server. It looks like the dev server package is meant to be used as a library (it's only a library crate), and having this external side effect feels unexpected and makes it difficult to use this crate in situations like a test runner for next-dev, where we should test with a headless web browser.

Alternatively, opening the browser could be an option passed when creating the dev server, but this feels a bit cleaner to me.

Test Plan: `cargo run -p next-dev` and verify the browser still opens and successfully connects to the dev server.
2022-07-27 19:09:11 +00:00
Tobias Koppers
eb417b1e25 cleanup compile target (vercel/turbo#157) 2022-07-27 11:36:10 +02:00
Tobias Koppers
d4a50bfd0c reduce number of clippy warnings (vercel/turbo#164) 2022-07-27 08:13:29 +00:00
LongYinan
a55a831b39 Node Module Trace webpack plugin (vercel/turbo#140)
* Initialize Node.js/TypeScript workspace

* node-module-trace Webpack plugin

* Add new fmt checks to pipeline

* Popup unwind error

* Implement --exact flag

* Yarn 3.2.2

* Reformat toml files

* Fix socket io test, 100ms timeout is too long

* remove unnecessary CI cache config

* regenerate lockfile from old lockfile, align the dependencies version

* Run nmt tests in system tmp dir

* Apply code review suggestions

* allow to wait for task completion and propagate errors and panics

* revert method addition

* spawn_root_task should be sync

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2022-07-22 12:36:08 +02:00
Tobias Koppers
144e95bc4e allow to switch to eager compiling 2022-07-21 13:22:42 +02:00
Tobias Koppers
fb1bc5a55f make websocket task special as it never completes
aggregate timings before displaying
2022-07-20 19:49:27 +02:00
Tobias Koppers
a12541a06a add performance table 2022-07-19 10:54:53 +02:00
Justin Ridgewell
099e5c7c4b next-dev: Fix watching relative directories
Fixes vercel/turbo#107
2022-07-18 17:56:26 -04:00
Tobias Koppers
aa64055055 add util for formating durations 2022-07-18 21:39:55 +02:00
Tobias Koppers
f134e1104c fixup paths 2022-07-18 18:11:13 +02:00
Tobias Koppers
85ae4b5036 add bootstrap logic for chunks 2022-07-13 08:37:12 +02:00
Leah
2909fd07ca fmt 2022-07-12 17:17:23 +02:00
Leah
cd647d7fc4 match next dev args 2022-07-12 17:09:16 +02:00
Tobias Koppers
99e015c41f complete strongly consistent read
performance improvements
2022-07-08 15:05:51 +02:00
Tobias Koppers
878dd09578 improve visualization
make TransientValue functional
make console-subscriber an optional feature
avoid cloning when calling a function
capture timings of task executions
fix LazyAsset
expose graph from dev server
2022-07-08 14:52:28 +02:00
Tobias Koppers
89f6ad1151 cleanup and documentation 2022-06-30 13:54:04 +02:00
Leah
667507c5ca don't like these quoted names lol 2022-06-29 18:09:41 +02:00
Tobias Koppers
db41ef8432 place the persistent cache behind a feature flag 2022-06-29 09:40:11 +02:00
Tobias Koppers
54985ab83d chunking and bugfixes 2022-06-28 10:21:04 +02:00
Tobias Koppers
b3df7a862e abstract lazy graph into Asset decorator
enable watching for dev server
2022-06-14 12:53:46 +02:00
Tobias Koppers
e7c2d1e932 add initial dev-server and next-dev cli 2022-06-14 12:53:46 +02:00