### Description
The isolation is unnecessary and we can reuse files when we share
directories
### Testing Instructions
Open multiple pages without client-side navigation in multiple tabs
concurrently.
### Description
Ensures `target` is optional to match vercel/turbo#46801 which removes the option.
<!--
✍️ Write a short summary of your work.
If necessary, include relevant screenshots.
-->
### Testing Instructions
<!--
Give a quick description of steps to test your changes.
-->
This:
* Adds a compile-time feature, `__internal_nextjs_integration_test`,
which is set when building Turbopack for the Next.js integration test
suite.
* When built with `__internal_nextjs_integration_test`, expects the
environment variable `NEXT_FONT_GOOGLE_MOCKED_RESPONSES` to be set with
an absolute path to a JavaScript file exporting a mapping of urls to
stylesheet text. This is used in place of making real requests to Google
Fonts.
* Addresses some small bugs in next/font/google to bring the
implementation in line with the urls generated by Next.js without
Turbopack.
* Changes classnames generated by next/font to use 6 character hashes,
bringing it in alignment with Next.js without Turbopack.
Test Plan:
* Adjusted existing unit tests
* In Next.js, `node run-tests.js -c 1 test/e2e/next-font/index.test.ts`
### Description
<!--
✍️ Write a short summary of your work.
If necessary, include relevant screenshots.
-->
### Testing Instructions
<!--
Give a quick description of steps to test your changes.
-->
<!--
When the below is checked (default) our PR bot will automatically
assign labels to your PR based on the content to help the team
organize and review it faster.
-->
- [x] Auto label
This implements webpack loader context api for `emitError` and
`emitWarning`, each of which emit Turbopack issues at the appropriate
error level. As with webpack’s implementation, `emitError` does _not_
cause builds to fail [0].
This uses next-dev issue snapshots (vercel/turbo#3774) to test that issues are
emitted.
[0] https://webpack.js.org/api/loaders/#thisemiterror
---------
Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
### Description
* use completions to signal additional invalidations for evaluation
* avoid adding these modules as runtime entries, since that will
unnecessarily code generate, bundle and execute these modules
* gets rid of the watch_files_hack
### Testing Instructions
* change postcss.config, next.config.js, etc. -> changes will be
reflected by the app and process restarts
### Description
Follow-up changes for https://github.com/vercel/turbo/pull/4018
<!--
When the below is checked (default) our PR bot will automatically
assign labels to your PR based on the content to help the team
organize and review it faster.
-->
- [x] Auto label
### Description
* get rid of attached filesystem for our embedded modules
* get rid of import "." in favor of inner assets
depends on vercel/turbo#3999
### Testing Instructions
existing tests
<!--
When the below is checked (default) our PR bot will automatically
assign labels to your PR based on the content to help the team
organize and review it faster.
-->
[X] Auto label
* add Asset::ident() as unique identifier of an Asset
* add ChunkItem::ident() instead of ChunkItem::to_string()
(ValueToString)
* base `chunk_path` on AssetIdent instead of path only
Motivation:
We want to get rid of the `import "."` in favor of inner assets. When
doing this we no longer need to place virtual assets below the actual
file path and they can stay in their original path. But placing virtual
assets below the actual asset also made the `Asset::path` unique, which
would no longer be the case after using inner assets. Some parts of the
code base relied on `Asset::path` being unique (e. g. module ids and
chunk paths). But actually we never guaranteed that to be unique.
After this PR `Asset::ident` is intended to be unique and allow to carry
more information than only the path:
* Query string (`module?query`)
* Fragment (`module#fragment`)
* Asset (additional wrapped assets by key value pairs)
* Modifiers (additional transformations applied on the module, e. g.
`chunks`, `client chunks`)
* In future: Part (select a subpart of the module, e. g. only export
abc, or the module evaluation, or some internal part)
Partially resolves WEB-671.
There are some test cases use `data-nextjs-dialog-header` to lookup its
inner text to verify error output. Due to differences of error overlay
layout between turbopack / next-dev, those 2 have different inner texts.
PR applies a workaround, by introducing new data tag
`data-nextjs-turbo-dialog-body`. Next.js upstream will need following
update to utilize this tag in its test suites.
This accomplishes 2 things:
- Moves the creation of the edge info onto the Next.js side
- Extracts the middleware's `export const config = {}`, so that we can know what matchers are needed before invoking the edge function definition.
After this, an update to the Next.js side will enable middleware.
Fixes WEB-623
This:
* Adds issue snapshot support to next-dev-tests. This will allow us to
assert that certain issues are raised in tests that require next-dev.
* Extracts common snapshot code into a new crates,
`turbopack-test-utils`, which is shared between snapshot tests and
next-dev-tests.
* Implements an issue reporter that emits issues in a channel to the the
integration test code, where they are snapshotted.
* Fixes an issue where next-dev tests that were not Next.js apps would
emit non-fatal issues for a missing `pages/` directory.
Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
---------
Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
This:
* Addresses feedback from https://github.com/vercel/turbo/pull/3862
* Exempts VirtualAssets from webpack loaders. This addresses a bug where
next-hydrate.tsx could not be read.
* Adds `ModuleRuleCondition::ResourceIsVirtualAsset` to filter these
---------
Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
This will automatically apply `babel-loader` to Next.js apps that
include a babel configuration file alongside `next.config.js`. It
requires the app to provide `babel-loader` itself.
Test Plan: Added an integration test.
This implements a new `ContentSourceProcessor` trait and
`WrappedContentSource` struct that allows our `ContentSource`s to
register some processor to transform the eventual `ContentSourceContent`
that an inner `ContentSource` returns. Yah, it's a bit of a mouthful
with lots of very similar sounding names.
Essentially, the old `SourceMapContentSource` and
`NextSourceMapTraceContentSource` wrapped some inner `ContentSource`,
and would request content from them, and process that content into a
source map JSON or trace JSON. But, they didn't implement the `NeedData`
response, so it only supported very primitive inner content sources.
This PR extracts that knowledge into a single `WrappedContentSource`,
which will recursively wrap every `ContentSourceResult` until we land on
a fully resolved `ContentSourceResult::Result`. At that point, it hands
off the work to a `WrappedGetContentSource`, which performs the
processing on whatever content is returned by the inner
`GetContentSourceContent`. If you can't tell yet, I'm making the
description intentionally verbose to highlight just how similar our
struct/trait names are.
Fixes WEB-614
This switches the `chunk_content_internal` function from a sequential
BFS to a parallel BFS (+ reverse topological sort at the end).
I expected this to make some difference in performance, as traversing
references in parallel can lead to better CPU usage (see vercel/turbo#3771), but in
practice our benchmarks show no significant difference.
Real apps might be a different story, but I didn't notice any particular
performance improvement on vercel.com either.
This implementation is not perfect (we're making more calls to
`get_children` than strictly necessary), but I think it's enough to
measure a potential performance improvement.
Marking this as a draft for now as it's more complicated than the
current implementation and there's no clear win to adopting this.
We now store react errors in the error overlay (hydration errors) and if
the error overlay receives the "build ok" message after that it will
hard reload the page to recover
define process.env.NODE_ENV to development for next-dev
define and set `process.turbopack`
---------
Co-authored-by: Will Binns-Smith <wbinnssmith@gmail.com>
We need to invalidate router node.js process when routes change for correctness
In future we can pass the routes list to next.js instead of only invalidating @jridgewell
We also need the separated structure for next build @alexkirsz
The benefit of this depends on
https://github.com/vercel/next.js/pull/45962, but it remains compatible
with apps including `loader-runner`.
This first attempts to require `loader-runner` from the app's installed
version of Next.js, falling back to requiring the package directly. We
should probably eventually remove this fallback once all compatible
versions of Next.js include the precompiled version, as that has a more
predictable version of the package.
Test Plan: Linked a local copy of Next.js including
https://github.com/vercel/next.js/pull/45962 to an app without
`loader-runner` that uses loaders and verified loaders ran.
Before the static evaluation didn't consider the fact that objects and arrays can be mutated. So we can't just assume for sure that they have certain properties/items. Instead we add an unknown mutation alternative to handle that.
This avoids `if(obj.prop)` to be replaced with `if(true)` when prop is initialized with true. It might be modified in future.
Another small cleanup stemming from the the `basePath` PR. Makes the
introspection ordering consistent, which is a nice usability win.
Co-authored-by: Alex Kirszenberg <1621758+alexkirsz@users.noreply.github.com>
This fixes 2 bugs that I've found:
1. If the `middleware.ts` file doesn't exist, then we get an unhelpful `unable to resolve relative "."` error during `next-edge` transition processing
- This is fixed by not processing the `VirtualAssetVc` with the edge transition
2. If you're using an older Next version, then the router doesn't have a `type` field
- Because the `type` field is empty, we hit neither the `rewrite` nor `none` cases and fall through to the middleware case, returning an empty response with no body.
- This is fixed by treating `{ url: string, headers: … }` as `{ type: 'rewrite', url: string, headers: … }`