Commit graph

268 commits

Author SHA1 Message Date
Justin Ridgewell
196ac9717c Fix React Refresh boundary finding for CSR (vercel/turbo#2574)
* Fix React Refresh boundary finding

We forgot to enable the transform, which means we were rendering from the root of the app instead of the changed component.

* Update snapshots

* Add comment

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-11-03 16:28:47 +01:00
LongYinan
e08865cafd Merge turbo crate into cargo workspace (vercel/turbo#2577) 2022-11-03 23:01:50 +08:00
Alex Kirszenberg
e8c027ffb2 Use mimalloc in next-dev (vercel/turbo#2467) 2022-11-03 07:01:39 +00:00
Tobias Koppers
beed9fb626 add benchmark documentation and blog post (vercel/turbo#2492)
Co-authored-by: Anthony Shew <anthony.shew@vercel.com>
Co-authored-by: Jared Palmer <jared@jaredpalmer.com>
Co-authored-by: Maia Teegarden <dev@padmaia.rocks>
Co-authored-by: Will Binns-Smith <wbinnssmith@gmail.com>
Co-authored-by: Alex Kirszenberg <alex.kirszenberg@vercel.com>
Co-authored-by: Matt Pocock <mattpocockvoice@gmail.com>
2022-11-01 00:08:56 +01:00
OJ Kwon
36daa2bf52 feat(next/dev): allow to retry bind (vercel/turbo#2480) 2022-10-30 12:05:37 -07:00
Tobias Koppers
091af50322 add TURBOPACK_BENCH_PROGRESS to show captured values during bench (vercel/turbo#2490) 2022-10-29 18:13:39 +02:00
Alex Kirszenberg
9b5c2e39ea Simplify benchmark warmup (vercel/turbo#2483)
* Simplify benchmark warmup

* Update crates/next-dev/benches/mod.rs

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>

* fmt

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2022-10-29 09:37:52 +02:00
Justin Ridgewell
9fc8c13877 Faster source map tracing (vercel/turbo#2426)
* Store the sourcemap::SourceMap directly, instead of encoding it

* Implement GenerateSourceMap trait and use it to retrieve live maps

* Cleanup and comments!

* Update safety comment

* Rename var

* Update snapshots

* Update snapshots

* Fix tracing errors in SSR

SSR has access to `EcmascriptChunkVc`, not `EcmascriptChunkContentVc`. Client gets access only to `EcmascriptChunkContentVc`

* Fix source map sources on client

Because the JS is nested in dirs, the source needs to be an absolute path.

Co-authored-by: Jared Palmer <jared@jaredpalmer.com>
2022-10-29 01:16:05 +02:00
Tobias Koppers
befc272a8c remove require hook (vercel/turbo#2473) 2022-10-29 00:24:25 +02:00
Tobias Koppers
f9fb452b32 improve startup and warmup of benchmarks (vercel/turbo#2463) 2022-10-28 21:56:33 +02:00
Tobias Koppers
69d98a5bde make sure to exit the process in case of errors during errors sending (vercel/turbo#2457) 2022-10-28 20:56:40 +02:00
OJ Kwon
2af748edd4 refactor(next/dev): reusable start_server (vercel/turbo#2455) 2022-10-28 09:41:46 -07:00
阿豪
5f00509321 chore: typo (vercel/turbo#2404)
* chore: typo

* Remove hot_module_replacement from snapshot tests

Re: vercel/turbo#2351

Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
2022-10-28 11:59:21 -04:00
Alex Kirszenberg
f2d661c0bb Fix large regression with turning ModuleRuleCondition::matches into a tt::fun (vercel/turbo#2450)
* Fix large regression with turning ModuleRuleConditionVc::matches into a tt::fun

* Remove Vcs from ModuleRule altogether
2022-10-28 17:53:13 +02:00
OJ Kwon
0d12445d6a refactor(next/dev): allow devserver args serializable (vercel/turbo#2446) 2022-10-28 08:28:04 -07:00
Allan
b12e0d8f46 Fix unnecessary question mark warnings (vercel/turbo#2443)
* Fix unused question marks warnings

Fix some return types that were giving clippy warnings, mostly `needless_question_mark`.
Remaining warnings are either `too_many_arguments` or `type_complexity`.

* Fix unncessary let binding

Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
2022-10-28 01:40:49 -04:00
Tobias Koppers
2e4f40ae31 prettier fixes (vercel/turbo#2436) 2022-10-28 00:39:56 -04:00
Alex Kirszenberg
eca1e994f1 Update Next.js dependency for the TP benchmark (vercel/turbo#2435) 2022-10-28 00:39:33 -04:00
Alex Kirszenberg
201259af94 More forgiving timeout when waiting for Node.js to connect (vercel/turbo#2417)
* More forgiving timeout when waiting for Node.js to connect

* 10ms -> 30s
2022-10-28 00:35:30 -04:00
Justin Ridgewell
d4cb480fca Source map tracing fixes (vercel/turbo#2402) 2022-10-27 21:30:30 -07:00
JJ Kasper
8788e1f7d1 Add Next.js require hook (vercel/turbo#2434)
This hook is needed to ensure we properly map compiled modules like `styled-jsx` correctly. 

x-ref: [slack thread](https://vercel.slack.com/archives/CGU8HUTUH/p1666824437456749?thread_ts=1666819473.031139&cid=CGU8HUTUH)
2022-10-27 22:19:47 +00:00
Will Binns-Smith
52da74e39d Implement nsObj helper from webpack tests and pass basic import test (vercel/turbo#2385) 2022-10-27 01:22:58 +02:00
Tobias Koppers
d80eb2e0a0 fix node.js 18.9 (vercel/turbo#302) 2022-10-25 10:19:03 +02:00
Tobias Koppers
9c352406ee sort errors by relevance (vercel/turbo#299) 2022-10-25 09:15:51 +02:00
Tobias Koppers
50ca47eb8f fix inconsistent asset writes (vercel/turbo#296) 2022-10-25 09:01:03 +02:00
Tobias Koppers
2bc7c10228 use error overlay in app layouts (vercel/turbo#294) 2022-10-25 08:33:16 +02:00
LongYinan
ce4a8ed6bb Fix format check (vercel/turbo#289) 2022-10-25 13:45:08 +08:00
Tobias Koppers
395dbc9402 improve node.js pool process error handling (vercel/turbo#287) 2022-10-25 07:05:16 +02:00
Alex Kirszenberg
7d6212b064 Use a TCP connection for IPC between Node and TP (vercel/turbo#251)
Instead of using stdout for communication between the Node.js process
and the Turbopack instance, this PR switches to a TCP connection.
Furthermore, stdout and stderr are now piped between the Node.js process
and Turbopack.
2022-10-25 05:31:08 +02:00
Alex Kirszenberg
880205ef37 Fix bad merge (vercel/turbo#281) 2022-10-24 19:42:55 -07:00
Tobias Koppers
150155b741 expose assets from fallback page (vercel/turbo#280) 2022-10-24 19:39:47 -07:00
Justin Ridgewell
c2bb12d0bf Fix tracing of node_modules files not emitted by pages (vercel/turbo#249)
Because the static SSR renderer doesn't emit files that exist in
`node_modules` (because we take advantage of node's native `require`
resolution), any paths that traced into `node_modules` would output the
full file system path. It's just verbose and annoying.

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2022-10-24 19:16:35 -07:00
Tobias Koppers
43d86a1bfa clippy (vercel/turbo#266) 2022-10-25 03:38:43 +02:00
Will Binns-Smith
dc74ca31c0 Create an app root layout if app/page.{js,tsx} exists but layout does not (vercel/turbo#264)
This makes turbopack automatically create `app/layout.js` if
`app/page.js` exists, or `app/layout.tsx` if `app/page.tsx` exists, and
neither layout file already exists.

**Note that I'd prefer this issue to have info severity, but even with a
higher log level of info, the issue is never shown**. Filed vercel/turbo#265 to
track this.

Test Plan:
In a new `create-next-app`, opt into appDirectory and create
`app/page.js`. Run turbopack and verify:
* [x] the index page renders correctly
* [x] An issue with Warning level is logged notifying the user an
`app/layout.js` was created
* [x] `app/layout.js` is actually created with basic root layout

In a new `create-next-app`, opt into appDirectory and create
`app/page.tsx`. Run turbopack and verify:
* [x] the index page renders correctly
* [x] An issue with Warning level is logged notifying the user an
`app/layout.tsx` was created
* [x] `app/layout.tsx` is actually created with basic root layout

In a new `create-next-app`, opt into appDirectory and create
`app/page.tsx`. Also create a basic `app/layout.js` (note js layout with
tsx page). Add a custom `<title>` to the layout. Run turbopack and
verify:
* [x] the index page renders correctly
* [x] No issue is logged
* [x] No files are modified
* [x] The custom `<title>` is reflected.
2022-10-24 17:30:04 -07:00
Alex Kirszenberg
c8067af03f Fix fallback page error overlay (vercel/turbo#268) 2022-10-24 17:05:21 -07:00
Tobias Koppers
dca015b121 move feature detection to next.js (vercel/turbo#263) 2022-10-24 16:19:14 -07:00
Tobias Koppers
233b69d203 App CSS and fixes (vercel/turbo#246)
fix app layout transition
add global css support
2022-10-25 00:27:17 +02:00
Tobias Koppers
36f7545c33 add HMR for RSC component changes (vercel/turbo#202) 2022-10-24 22:23:40 +02:00
Alex Kirszenberg
09273bdab1 Apply Next SSG transform (vercel/turbo#130)
This adds the Next SSG transform. This transform does a few things, but
the one we're most interested in right now is the removal of
`getStaticProps`/`getServerSideProps`/etc. from page modules. HMR will
be disabled if these exports are preserved.

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2022-10-24 22:23:00 +02:00
Justin Ridgewell
e4f6bbf6ab Implement source map tracing for errors (vercel/turbo#227)
Fixes https://github.com/vercel/web-tooling-internal/issues/67
2022-10-24 22:21:12 +02:00
Alex Kirszenberg
b0d8d36429 Add back Next's React compiled dists (vercel/turbo#209)
Required to get the layout-playground demo working.
2022-10-23 18:34:13 -07:00
Tobias Koppers
8fa162d5c5 fix app layouts (vercel/turbo#190)
Seems like app layout was left behind while shipping features to normal
SSR rendering

* fixes fallback error pages (update to error fallback changes)
* fixes process communication (update to api route changes)
* avoid busy looping
* update to next.js updates
* fix resolving cycle
* fix HMR of client components
* add some hard coded external packages
2022-10-22 19:47:59 +02:00
OJ Kwon
722930a006 feat(devserver): try to bind instead of explicit (vercel/turbo#187)
This PR attempts to try to bind server and bubbles up error, instead of
explicit `bind` which panics internally if it wasn't possible to bind.
2022-10-21 19:54:24 -07:00
Will Binns-Smith
4569ef779d Transform ecmascript with emotion (vercel/turbo#170)
Enabled in next-dev and snapshot tests.

There are quite a few output snapshot files. Maybe we make stubs for the
third-party packages to reduce the noise...

Test Plan: Added new snapshot tests. Verified transformed code contains
a digest, inline source map string.
2022-10-21 12:31:01 -07:00
Alex Kirszenberg
243bc9fbc0 Add support for API routes (vercel/turbo#163)
This reworks our Node.js rendering logic to allow for:
* passing binary request bodies in and out of Node.js: API routes can
accept request bodies in POST, and can reply with any content type.
* content source results that are recomputed every time: we don't want
API routes to be cached (at least not by turbopack for now).

It also reworks the `END_OF_OPERATION` logic to avoid hard coding a
single end of operation marker (they're now unique per pool), and allow
multiple kinds of operation events (`Step`, `Success`, `Error`).

This is not a particularly good implementation for this. A better
implementation would proxy the request from the client to the Node.js
server in a more direct manner. We also need a way to tell turbo tasks
"don't bother ever caching this", as right now every single API request
and result will still be cached, even if we know they will never be used
again. Finally, we should communicate with Node.js processes via a
better mechanism than stdout. I made some progress on a prototype for
using https://github.com/servo/ipc-channel with NAPI a while back, which
I'd like to pick up some time after conf.

However, it seems to work well enough for now, so yay.

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2022-10-21 21:03:52 +02:00
Tobias Koppers
06cc52ecbc remove fouc optimization (vercel/turbo#169) 2022-10-21 20:44:29 +02:00
Will Binns-Smith
dd7278c0e3 Next-dev and snapshot tests: transform ecmascript with styled_components (vercel/turbo#44)
To do:
* [x] The transform doesn't seem to be running properly yet. Fix this.
2022-10-21 09:32:39 -07:00
Will Binns-Smith
7b4f51f8fb Create a package.json with type: "commonjs" in .next/server (vercel/turbo#145)
Closes vercel/turbo#109

Note a difference between this and stable Next.js: at turbopack this
file is placed in .next/server/package.json, while Next.js currently
creates this file at .next/package.json.

Test Plan: Verified that the `hello-world-esm` no longer fails to SSR
(it's now blocked by vercel/turbo#111).

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2022-10-21 08:38:56 -07:00
Tobias Koppers
7d8d351d5e fix hydration bench again (vercel/turbo#162) 2022-10-21 16:29:52 +02:00
Tobias Koppers
451dccdeb8 fix startup benchmarks for CSR bundlers (vercel/turbo#152) 2022-10-21 16:11:25 +02:00
Tobias Koppers
790ff6c05c add some strongly consistent reads into nodejs source (vercel/turbo#154)
to improve performance

It doesn't fix the performance completely but makes it less bad
2022-10-21 14:23:49 +02:00
Tobias Koppers
d1db10cd37 Bugfixes for merged PRs (vercel/turbo#155) 2022-10-21 12:44:40 +02:00
Florentin / 珞辰
b1caa9ec34 terminal improvements (vercel/turbo#133)
* Adds next-like event type styling
* No tasks in logs

Closes:
- https://github.com/vercel/web-tooling-internal/issues/58

Screenshot: 
![CleanShot 2022-10-20 at 17 59
45@2x](https://user-images.githubusercontent.com/8146736/196999636-dcf3757d-6c5f-4c52-9257-86caabf6a5d6.png)

Co-authored-by: Maia Teegarden <dev@padmaia.rocks>
Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2022-10-21 11:50:37 +02:00
Justin Ridgewell
a442eab26e Update default server IP to 0.0.0.0 (vercel/turbo#150)
Small nit, but if we want to listen on 0.0.0.0, then we should set that
to the default. The difference is that other computers can connect when
we listen on 0.0.0.0, while only this computer can connect if we listen
on 127.0.0.1.
2022-10-21 02:01:54 -04:00
Maia Teegarden
ff5f95fd47 Match Next.js server startup message (vercel/turbo#148)
![Screen Shot 2022-10-20 at 8 13 41
PM](https://user-images.githubusercontent.com/2865858/197102924-5970972b-7177-4c30-b7b2-35932d2c66fb.png)
2022-10-20 22:27:27 -07:00
Leah
88d0a40a96 fix tests (vercel/turbo#143) 2022-10-21 02:28:46 +02:00
Leah
276c844152 prettier fixes (vercel/turbo#41) 2022-10-21 01:46:26 +02:00
Chris Olszewski
d87b96bb49 add postcss and tailwindcss to unimplemented files (vercel/turbo#137)
Note that this doesn't completely close out
[vercel/turbo#54](https://github.com/vercel/web-tooling-internal/issues/54) as the
[tailwindcss config is
optional](https://tailwindcss.com/docs/configuration). I'm digging
deeper at additional ways to detect tailwind, but putting this up since
it's a strict improvement.

```
olszewski@chriss-mbp next-dev % cargo run -p next-dev -- /tmp/with-tailwindcss-app
   Compiling next-dev v0.1.0 (/Users/olszewski/code/vercel/the-three-body/crates/next-dev)
    Finished dev [unoptimized + debuginfo] target(s) in 11.61s
     Running `/Users/olszewski/code/vercel/the-three-body/target/debug/next-dev /tmp/with-tailwindcss-app`
server listening on: http://localhost:3000
error [unimplemented]
  /private/tmp/with-tailwindcss-app/next.config.js
    Feature not yet supported
    Handling the file `next.config.js` is currently unimplemented

  /private/tmp/with-tailwindcss-app/postcss.config.js
    Feature not yet supported
    Handling the file `postcss.config.js` is currently unimplemented

  /private/tmp/with-tailwindcss-app/tailwind.config.js
    Feature not yet supported
    Handling the file `tailwind.config.js` is currently unimplemented

[200] / (3045ms)
initial compilation 3468ms (3044ms task execution, 48380 tasks)
updated in 874ms (8990 tasks)
```
2022-10-20 19:03:17 -04:00
Will Binns-Smith
3cb06901df Derive a runtime version from NodeJsEnvironment's node_version (vercel/turbo#15)
Ported from https://github.com/vercel/turbo-tooling/pull/452.

To do:

* [x] Read and use node version from PATH

Test Plan:

Temporarily lowered the default version and verified core-js was
resolved when /page is visited.

Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
2022-10-20 14:46:47 -07:00
Leah
ca98d275cf fallback page (vercel/turbo#69) 2022-10-20 22:26:53 +02:00
Leah
12d723059b prepare crates for publishing (vercel/turbo#29) 2022-10-20 19:49:35 +02:00
Florentin / 珞辰
2eae9f180c add unimplemented warning for next/babel configs (vercel/turbo#124)
PR for: 
- https://github.com/vercel/web-tooling-internal/issues/56
- https://github.com/vercel/web-tooling-internal/issues/55

Screenshot:
<img width="662" alt="CleanShot 2022-10-20 at 11 12 13@2x"
src="https://user-images.githubusercontent.com/8146736/196907628-e5c73d54-87a7-4f3a-9130-d08bc539a5b1.png">

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2022-10-20 18:53:27 +02:00
Tobias Koppers
3ca2fe4fd5 adds support for app directory (vercel/turbo#125)
This can be tested with https://github.com/vercel/layouts-playground

But since tailwind is not supported you need to add:

``` html
<script src="https://cdn.tailwindcss.com/3.1.6"></script>
```

into `<head>` in `app/layout.tsx`
2022-10-20 18:49:12 +02:00
Leah
4bb347ae39 error overlay (vercel/turbo#39)
transferred from https://github.com/vercel/turbo-tooling/pull/396

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2022-10-20 18:04:19 +02:00
Justin Ridgewell
be1537881c DeterminsticHash cleanup (vercel/turbo#108)
Fixes a few issues:

1. Removes `Hasher` impl for `Xxh3Hash64Hasher`
- Importing the `Hash` trait allows you to call `vc.hash(&mut
xxh3_hasher)`, which defeats our goal of deterministic hashing
2. Fixes hashing of 2 contiguous strings
   - `"fo"` and `"o"` should hash differently than `"f"` and `"oo"`.
3. Fixes hashes of enums
   - `Foo::Bar(1)` should hash differently than `Foo::Baz(1)`
4. Standardizes `usize`/`isize` as 8 bytes
2022-10-19 18:21:29 -04:00
Tobias Koppers
c5bc290c32 add node: prefixed aliases for polyfills (vercel/turbo#102) 2022-10-19 18:07:28 +02:00
Alex Kirszenberg
aff0a0f7c5 Fix CSS HMR for SSR (vercel/turbo#85)
Since we used to build the HTML using our own `<Document>` component, we
were previously adding a data-turbopack-chunk-id attribute to our
`<link>` tags to reconcile chunk paths with their chunk ids when
initializing HMR. However, Next.js is now responsible for building the
HTML, and it has no such mechanism.

**NOTE:** HMR is currently broken for non-Next-SSR rendering
(HtmlAsset). This PR does not fix that.
2022-10-19 18:06:40 +02:00
Tobias Koppers
381badcde3 Improvements to benchmarks (vercel/turbo#99)
* remove 100 modules form the default modules count
* rename bench_restart -> bench_hydration_cached
* add bench_startup_cached
* run npm install only once per test case and copy the result instead
* use multi-threaded copy
* Run `cached` tests only when `TURBOPACK_BENCH_CACHED` is set
* add `TURBOPACK_BENCH_BENCH` too measure the time it takes to run the
full benchmark (including startup and teardown) instead.
* add `TURBOPACK_BENCH_HEAD` to run non-headless
* add `TURBOPACK_BENCH_DEVTOOLS` to auto open devtools
* retry initial warmup change when it fails to detect that

This should make the benchmarks about 3 times faster... at least on
windows^^
2022-10-19 13:39:05 +02:00
Tobias Koppers
06ee2efe8e remove get_by_id (for performance) (vercel/turbo#88)
I also needed to remove the old html runtime, use new runtime for CSP to
update the CSS HMR code
2022-10-19 07:33:58 +02:00
Leah
0f40ec8327 ts HMR runtime (vercel/turbo#38) 2022-10-18 20:37:33 +02:00
Will Binns-Smith
50ab6dab18 [Rebased] Remove automatic core-js polyfills (vercel/turbo#91)
Rebase of vercel/turbo#68, which was merged into a now-closed PR.

Closes vercel/turbo#65.

When configured to use preset-env, this stops turbopack from inserting
dependencies on core-js. It's:

* Buggy/error-prone, at least through swc preset-env: 
  * https://github.com/vercel/the-three-body/issues/65
* setImmediate "polyfills" always inserted for this nonstandard feature
when
    React (scheduler, iirc) does feature detection of it
* Big. Updating the snapshot alone for a test that only used [].includes
  resulted in a diff with nearly 4700 line deletions
* Not done by Next.js for modern targets in the past couple of years:
https://twitter.com/timneutkens/status/1234548900272517120

Test Plan: Added [].includes to preset_env snapshot test and verified no
references to core-js are inserted.
2022-10-18 11:04:41 -07:00
Alex Kirszenberg
7bf4a27e6a Ensure Next.js uses React 18 APIs, enable styled_jsx transform in SSR (vercel/turbo#90)
This will remove the warning about using `hydrate` instead of
`hydrateRoot`, and fix a mismatch between SSR and CSR when using
styled-jsx (`<style jsx>`).
2022-10-18 19:30:46 +02:00
Alex Kirszenberg
9062ad91f4 Add polyfills to Node.js externals on the client-side (vercel/turbo#89)
We can't use the normal `ImportMap` because we stop resolving if looking
up a request within yields a result. However, for module polyfills, we
only need to look up the request when normal resolving fails. Hence the
dichotomy between the `import_map` and the `fallback_import_map`.

In a more modular architecture, we would model this as a stack of three
resolvers:

1. ImportMapResolver
2. DefaultResolver
3. FallbackImportMapResolver

I'm guessing this is what we'll have in the future, but this requires a
bigger refactoring than what I'm comfortable with implementing for now.
2022-10-18 19:30:07 +02:00
Alex Kirszenberg
59b7290933 Remove unused pages/_app and pages/_document (vercel/turbo#78)
These are no longer used, as we are now using Next.js' own components
instead.
2022-10-18 14:53:01 +02:00
Tobias Koppers
105ff16578 remove ContentSource::vary to avoid many tasks (vercel/turbo#71) 2022-10-18 13:00:10 +02:00
Justin Ridgewell
feb8c9ac39 Implement support for static assets directory (vercel/turbo#73)
Fixes https://github.com/vercel/web-tooling-internal/issues/7

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2022-10-18 10:05:37 +02:00
Tobias Koppers
5c1d113f1e node.js needs a fetch polyfill (vercel/turbo#58) 2022-10-18 09:56:24 +02:00
Tobias Koppers
aed7fa4d0b add basic support for browser alias field (vercel/turbo#56) 2022-10-18 03:17:06 +02:00
Leah
fcc806e1e5 embedded next.js package (vercel/turbo#37) 2022-10-17 23:33:25 +02:00
Alex Kirszenberg
44c2e1f570 Optimize Next.js SSR (vercel/turbo#48)
This PR also includes the changes in vercel/turbo#12 

This optimizes Next.js SSR by marking `react[/*]` and `next[/*]` imports
as externals in Node.js, which means that they will be `require`d
directly instead of bundled.

This optimization reduces the number of modules to analyze on the server
for a single component app from ~1000 (Next.js SSR imports a lot of
modules, including amp-optimizer which includes more) to <10.

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2022-10-17 19:54:19 +02:00
Tobias Koppers
2f3edac20c add introspection for assets and content sources (vercel/turbo#47)
add very simple explorer to introspect the graph via `/__turbopack__/`

Allows to "walk" through the content sources and asset graph. Some
assets allows to access inner assets, e. g. from the ecmascript chunk
you can access the entry module asset, so you can go a level deeper.

It works by a `Introspectable` trait which can be implemented by
anything we want to allow the user to inspect. In future the in browser
UI should offer a nice UI to explore your application.

In future we probably also want to add some `metrics` to the
`Introspectable` trait, e. g. to report size of an asset.

This UI is very basic currently, but that works for debugging:


![image](https://user-images.githubusercontent.com/1365881/196007862-2fb2a0e9-19ba-45c5-8a82-926418e0d479.png)
2022-10-17 17:19:29 +02:00
Tobias Koppers
3c821767ce use browser field for the browser (vercel/turbo#26)
add module field
2022-10-17 08:36:30 +02:00
Tobias Koppers
cabb72fa53 avoid emitting source maps for node.js (vercel/turbo#30) 2022-10-16 10:39:18 +02:00
Leah
f39152cef6 add From<T> impl for File (vercel/turbo#35)
transferred from https://github.com/vercel/turbo-tooling/pull/519
2022-10-15 18:42:14 +02:00
Leah
003a1ed013 add FileSystem::root() function to replace FileSystemPathVc::new(fs, path) (vercel/turbo#34)
transferred from https://github.com/vercel/turbo-tooling/pull/518
2022-10-15 18:40:02 +02:00
Tobias Koppers
280e909131 Deduplicate issues for logging (vercel/turbo#27)
see https://github.com/vercel/turbo-tooling/pull/523

Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
2022-10-14 17:52:59 +02:00
Tobias Koppers
8cab8aa1d6 windows needs magic SystemRoot env var to allow to make http requests from node.js (vercel/turbo#22) 2022-10-14 00:45:39 +02:00
Tobias Koppers
79ea25f491 make less things to rely on HashSet and HashMap order 2022-10-13 18:16:12 +02:00
Tobias Koppers
4760f0dbfd improve startup error messages (vercel/turbo#524) 2022-10-13 23:38:19 +08:00
Alex Kirszenberg
0527d39665 Turn the default Document component into a class component (vercel/turbo#512)
Some code in userland can expect Document to be a class, and as such try to extend it. Extending a function will result in an invalid React component, so it must be a class component.

e.g. https://nextjs.org/docs/advanced-features/custom-document#typescript
2022-10-13 09:29:20 +08:00
Alex Kirszenberg
1d46acd4d4 Introduce PathRegex for patch matching with named parameters (vercel/turbo#511)
This is another attempt at fixing https://github.com/vercel/turbo-tooling/pull/507. It also handles the root index page properly ("pages/index.js").
2022-10-13 09:29:19 +08:00
Tobias Koppers
a28aead85b use react-refresh-utils bundled with next when available (vercel/turbo#509) 2022-10-13 09:29:19 +08:00
Tobias Koppers
d5ed7e3940 routing bugfixes (vercel/turbo#495) 2022-10-11 10:23:10 +00:00
Tobias Koppers
8589c15b95 avoid creating too many content sources (vercel/turbo#496) 2022-10-11 10:23:00 +00:00
Tobias Koppers
fb1629c542 continue preparations for .module.css (vercel/turbo#494)
split global css and module css into separate assets
2022-10-11 09:47:43 +00:00
Tobias Koppers
5e1922d397 move node.js rendering to a content source (vercel/turbo#486)
add getServerSideProps and dynamic segments

fixes vercel/web-tooling-internal#37
fixes vercel/turbo#444
2022-10-10 22:21:30 +00:00
Tobias Koppers
3a05f60d3c fix many root sources crated (vercel/turbo#485)
It's important to not create a `cell` outside of the root `source` method as this will create a new cell for each call, which means each `source` will create a separate task, and this bubbles for each cell created in `source`...
2022-10-10 13:44:42 +00:00
Alex Kirszenberg
7ebb64846c Make embed_file relative to package instead of invoker file (vercel/turbo#484)
This makes the argument to `embed_file!` relative to the package it is invoked from, instead of relative to the file it is invoked from. The latter is closer to how `include_*!` works, but it has a couple of issues:
* Since `file!` returns a path relative to the workspace, it requires knowing the full path to the workspace. However, this is undefined when the package is compiled from outside of the workspace (e.g. as a dependency of another package).
* Procedural macros don't have access to the path of the file where they were originally invoked [(although we could get it with #[feature(proc_macro_span)])](https://doc.rust-lang.org/proc_macro/struct.Span.html), which means that an `embed_dir` macro would not be able to be relative to the invoker file anyway. So this makes things more consistent for such a (to be implemented) macro.
2022-10-10 13:35:42 +00:00
Will Binns-Smith
9bc858fddd preset_env followup [1/2] (vercel/turbo#478)
Addresses some feedback from vercel/turbo#380. Together with a following PR to use swc_core (currently blocked on https://github.com/swc-project/swc/pull/6083 and a subsequent publish), will address vercel/turbo#474.

* Remove unnecessary Result type
* Remove unnecessary @swc/helpers
2022-10-10 14:46:36 +02:00
Alex Kirszenberg
ed769521f9 Support for App.getInitialProps/Page.getInitialProps (vercel/turbo#464)
This is a very simplified version of what Next.js does. It adds support for `App` and page components defining `getInitialProps`.

fixes vercel/web-tooling-internal#38
2022-10-10 09:03:25 +00:00