Commit graph

214 commits

Author SHA1 Message Date
Tobias Koppers
86c46edce7
source map fixes (#61723)
### What?

* show guessed original file for generate code
* avoid internal cast
* add get_source_map method
* hide turbopack runtime stack lines
* hide unmapped stack lines


Closes PACK-2400

Before:


![image](https://github.com/vercel/next.js/assets/1365881/29f24f59-7c77-4496-92de-efcc72d28ad5)

After:


![image](https://github.com/vercel/next.js/assets/1365881/ca07e9f9-71ea-440d-97a2-c2c731ab3899)

and expanded:


![image](https://github.com/vercel/next.js/assets/1365881/1f73e632-890d-4681-8f21-ef502c676aae)

### Other Turbopack changes


* https://github.com/vercel/turbo/pull/4235 <!-- Leah -
chore(turborepo-lib): use compile error for feature validation -->
* https://github.com/vercel/turbo/pull/7285 <!-- Tobias Koppers -
resolve source maps that are attached in source code -->
* https://github.com/vercel/turbo/pull/7301 <!-- Donny/강동윤 -
fix(turbopack): Reverse order of css chunks to fix css module issues -->
* https://github.com/vercel/turbo/pull/7286 <!-- Tobias Koppers - guess
original source for generated code -->
2024-02-07 08:58:08 +01:00
OJ Kwon
9cadae5eef
feat(next-swc): support wasm32-* build target (#61586)
<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### How?

Closes NEXT-
Fixes #

-->

### What?

This PR introduces a ground work to generate wasm bindings package from
our napi bindings. This doesn't actually replace anything yet, however
aim to establish our napi bindings package can be built against wasm32
target.

### Why?

We currently have two bindings package to generate native / wasm target
support, one for napi and one other for wasm. Recently napi-rs started
to support to generate bindings for the wasm directly - which means we
can get rid of the wasm-pack based bindings code entirely and maintain a
single bindings code only.

This'll makes our `next-swc` simpler as well, since the invocation to
the bindings now becomes identical we don't have to additional wasm
specific logics to invoke functions (i.e transform, transformsync..).
Also napi generates wasi-supported wasm bindings, provides few more
features to the current wasm bindings.

#### Good
- Async napi binding fn works transparently (`transform`, `minify`...)
- (Experimental) thread supports depends on node.js runtime
- Wasi support: i.e it can even read filesystem directly!

#### Things to consider
- node.js's wasi support is experimental yet
- napi-rs's wasm support is in beta yet, specifically `packaging`
generated wasm output.

Due to `things to consider` reasons, this PR does not replace existing
wasm target yet. We should be able to plan out things later.

**What happens to the turbopack api in napi bindings?**

Simply put, this **does not support turbopack in wasm**. Build works by
disabling turbopack (more notably, underlying dependency doesn't support
wasm) features. It is something to explore separately.


Closes PACK-2367


There is a branch at https://github.com/vercel/next.js/pull/61586 shows
quick demo for importing, running sync / async / read external files.
2024-02-06 10:15:13 -08:00
Leah
f910e2bdcd
chore: update turbopack (#61682)
### Turbopack Updates

* https://github.com/vercel/turbo/pull/7240 <!-- OJ Kwon -
refactor(turbopack): remove deprecated options -->
* https://github.com/vercel/turbo/pull/7241 <!-- Will Binns-Smith -
Turbopack: Fix Next.js in cross-bundler benchmarks -->
* https://github.com/vercel/turbo/pull/7274 <!-- Leah - fix(turbopack):
support reloading typescript tailwind config -->

Fixes #61607
2024-02-06 14:40:15 +01:00
OJ Kwon
b95e45a511
build(cargo): bump up turbopack (#61590)
* https://github.com/vercel/turbo/pull/7213 <!-- OJ Kwon -
feat(turbopack): extend ecmatransform moduleeffect -->
* https://github.com/vercel/turbo/pull/7219 <!-- Leah - fix(turbopack):
encode source map urls -->
* https://github.com/vercel/turbo/pull/7220 <!-- Leah -
style(turbopack): make idents more readable -->

Closes PACK-2369
2024-02-02 12:22:42 -08:00
Donny/강동윤
a77f8a9165
Update turbopack (#61553)
# Turbopack

* https://github.com/vercel/turbo/pull/7207 <!-- Donny/강동윤 -
feat(turbopack): Enable error recovery of lightningcss -->
* https://github.com/vercel/turbo/pull/7096 <!-- Tobias Koppers -
migrate type references to primary references -->
* https://github.com/vercel/turbo/pull/7225 <!-- Donny/강동윤 -
fix(turbopack): Fix css var issue and font issue when using
`lightningcss` -->

### What?

Update turbopack 

### Why?

To test https://github.com/vercel/turbo/pull/7225 against internal apps.


### How?



Closes PACK-2364
2024-02-02 08:27:00 +00:00
Donny/강동윤
fafcb5fbfe
Update turbopack (#61433)
# Turbopack

* https://github.com/vercel/turbo/pull/7167 <!-- Leah - fix: catch
import map lookup error properly in `ResolvingIssue` -->
* https://github.com/vercel/turbo/pull/7182 <!-- Donny/강동윤 - feat:
Re-enable `preset-env` mode of `styled-jsx` in turbopack -->
* https://github.com/vercel/turbo/pull/7161 <!-- Tobias Koppers - add
support for globs in sideEffects field in package.json -->
* https://github.com/vercel/turbo/pull/7184 <!-- Donny/강동윤 - chore:
Update `swc_core` to `v0.89.6` -->

### What?

Update turbopack

### Why?

To test https://github.com/vercel/turbo/pull/7182 against internal
webapps.

### How?

 - Closes #57718

Closes PACK-2334
2024-01-31 19:33:37 +09:00
Donny/강동윤
ead21691b6
chore: Update swc_core to v0.89.6 (#61426)
### What?

Update SWC crates

### Why?

To apply the latest bugfixes

### How?

Fixes #40385



Closes PACK-2332
2024-01-31 18:35:20 +09:00
Donny/강동윤
292cd0d377
Update turbopack (#61381)
# Turbopack changes
* https://github.com/vercel/turbo/pull/7160 <!-- Will Binns-Smith - Make
`EcmascriptDevChunkContent` public to other crates -->
* https://github.com/vercel/turbo/pull/7162 <!-- Tim Neutkens - Fix
sourcemap PR compile error -->
* https://github.com/vercel/turbo/pull/7163 <!-- Donny/강동윤 - fix: Revert
`preset-env` mode of `styled-jsx` in turbopack -->


### What?

Update turbopack

### Why?

To apply https://github.com/vercel/turbo/pull/7163

### How?



Closes PACK-2323
2024-01-30 14:29:12 +01:00
Leah
e4b3531377
fix(turbopack): don't parse .ts files as .tsx (#61219)
### What?

We currently parse JSX syntax in all typescript files which is wrong.

Closes PACK-2302

Turbo PR: https://github.com/vercel/turbo/pull/7121

### Turbopack Updates

* https://github.com/vercel/turbo/pull/7099 <!-- Donny/강동윤 -
fix(turbopack): Fix panic from `EcmascriptModuleFacadeModule::content`
-->
* https://github.com/vercel/turbo/pull/7121 <!-- Leah - fix(turbopack):
don't parse `.ts` files as `.tsx` -->
2024-01-29 21:13:32 +00:00
Donny/강동윤
2d9ea76af3
Update swc_core to v0.89.4 (#61285)
### What?

Update swc crates.

### Why?

To fix the build issues of vercel sites.

### How?



Closes PACK-2304
2024-01-29 02:09:44 +00:00
Donny/강동윤
7b9d90bcdc
Update swc_core to v0.89.x (#61086)
## Turbopack

* https://github.com/vercel/turbo/pull/7092 <!-- Donny/강동윤 - Update `swc_core` to `v0.89.x` -->


### What?

Update SWC crates

### Why?

To fix some issues

### How?

Fixes #59805
Fixes #56144


Closes PACK-2222
Closes PACK-2285
2024-01-27 09:43:57 +00:00
Tim Neutkens
edc658a5cc
Upgrade Turbopack (#61190)
* https://github.com/vercel/turbo/pull/7104 <!-- Will Binns-Smith -
Turbopack: use inline sourcemaps for HMR chunks -->

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->


Closes NEXT-2248
2024-01-26 10:45:25 +01:00
Leah
ae12b30464
chore: update turbopack (#61090)
### Turbopack Updates

* https://github.com/vercel/turbo/pull/7091 <!-- Tobias Koppers - lock
reqwest to 0.11.17 due to build issues -->
* https://github.com/vercel/turbo/pull/7080 <!-- Tobias Koppers - reduce
work and tasks during module analysis -->
* https://github.com/vercel/turbo/pull/7093 <!-- Leah - fix: don't
escape base path in ecmascript runtime to allow for URLs -->

Closes PACK-2282
Fixes #60891 via https://github.com/vercel/turbo/pull/7093
2024-01-24 20:44:42 +00:00
Tobias Koppers
30a5d96870
lock reqwest to 0.11.17 due to build issues (#61076)
### Why?

otherwise the build fails on aarch64-unknown-linux-gnu

build-and-deploy action:
https://github.com/vercel/next.js/actions/runs/7638354515/job/20809074561


Closes PACK-2287
2024-01-24 11:22:58 +01:00
Donny/강동윤
014b212388
Update swc_core to v0.87.28 (#60876)
# Turbopack

* https://github.com/vercel/turbo/pull/7027 <!-- Donny/강동윤 - Update `swc_core` to `v0.87.28` -->

---

### What?

Update swc crates

### Why?

Required for #57718.
`styled-jsx` crate now has a hook to transform CSS code using a
Rust-side API

### How?

Fixes #57718



Closes PACK-2256
2024-01-24 08:05:05 +00:00
Tim Neutkens
59e042a9a7
Implement client_root for edge in Turbopack (#61024)
## What?

Implements https://github.com/vercel/turbo/pull/7081. Ensures image
imports in the edge runtime have the correct asset url. Previously it
would be `/assets/file.hash.png` but it should be
`/_next/static/media/file.hash.png`.

Updates the image tests to correctly compare the values in Turbopack and
the values in Webpack. Currently it only checks webpack values, causing
the tests to fail in Turbopack.

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->


Closes NEXT-2194
2024-01-23 18:41:02 +01:00
Tobias Koppers
a7a403f498
update turbopack (#61015)
* https://github.com/vercel/turbo/pull/7067 <!-- Tobias Koppers - fix a
hanging issue with strongly consistent reads -->
* https://github.com/vercel/turbo/pull/7068 <!-- Tobias Koppers - add
lazy_remove_children feature flag -->
* https://github.com/vercel/turbo/pull/7073 <!-- OJ Kwon -
fix(ecmascript): collect recoverable error after parse -->

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2024-01-23 14:35:17 +01:00
Tobias Koppers
3a7fea4034
Revert "refactor(analysis): rust based page-static-info, deprecate js parse interface in next-swc" (#61021)
Reverts vercel/next.js#59300

Breaks `app/page.mdx` files

Closes PACK-2279
2024-01-23 12:00:36 +01:00
OJ Kwon
9d5f62eb4a
refactor(analysis): rust based page-static-info, deprecate js parse interface in next-swc (#59300)
### Description

This PR refactors existing `analysis/get-static-page-info`, moves over
most of parse / ast visiting logic into next-swc's rust codebase. By
having this, turbopack can reuse same logic to extract info for the
analysis. Also as a side effect, this removes JS side parse which is
known to be inefficient due to serialization / deserialization.

The entrypoint `getPageStaticInfo` is still in the existing
`get-page-static-info`, only for extracting / visiting logic is moved.
There are some JS specific context to postprocess extracted information
which would require additional effort to move into.


Closes PACK-2088
2024-01-22 14:42:28 -08:00
Will Binns-Smith
5f67de6717
Rust: update http to 0.2.11 (#60986)
This aligns the version with that in https://github.com/vercel/turbo


Closes PACK-2272
2024-01-22 19:31:45 +00:00
Leah
f5dab7ce7d
chore: update turbopack (#60980)
### Turbopack Updates

* https://github.com/vercel/turbo/pull/6923 <!-- Tobias Koppers - Bottom
up tracing and some tracing improvements -->
* https://github.com/vercel/turbo/pull/7028 <!-- Leah - fix: add missing
layer ident modifier to asset with inner assets -->

Closes PACK-2270
2024-01-22 17:03:22 +01:00
Tim Neutkens
4548fed1cf
Skip postcss config location resolving in node_modules (#60697)
## What?

Skip postcss config resolving in node_modules for Turbopack. This
matches current Next.js on webpack closer as that only resolves the
postcss config from the project root. The additional feature Turbopack
has is that it can find a postcss config relative to the css being
compiled. This is useful for e.g. reducing the amount of overhead
certain postcss plugins that only have to run against a single file take
(i.e. Tailwindcss).


Depends on github.com/vercel/turbo/pull/7012 landing first.

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->


Closes NEXT-2109

---------

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2024-01-17 13:54:17 +00:00
OJ Kwon
5956ff76b5
feat(next-core): port remaining next.js custom transforms (#60498)
<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?



-->

This PR ports over all of the remaining custom transforms for next-swc
into turbopack, and apply it into client / server rules accordingly.

Closes PACK-2225
2024-01-17 10:32:58 +01:00
Tobias Koppers
4597ff35da
allow to pass available chunk items when creating a chunk group (#60554)
### What?

api changes for https://github.com/vercel/turbo/pull/6988

### Turbopack Changes

* https://github.com/vercel/turbo/pull/6886 <!-- Tobias Koppers -
improve nesting of tracing for invalidations -->
* https://github.com/vercel/turbo/pull/6866 <!-- Tobias Koppers - trace
memory allocations and show in tracing -->
* https://github.com/vercel/turbo/pull/6988 <!-- Tobias Koppers - allow
to pass available chunk items when creating a chunk group -->
* https://github.com/vercel/turbo/pull/7013 <!-- Leah - fix: make CSS
reloading work on firefox -->
* https://github.com/vercel/turbo/pull/7004 <!-- Tobias Koppers -
improve error message when no config is exported from postcss.config.js
-->




Closes PACK-2231
2024-01-17 08:58:02 +01:00
OJ Kwon
8627e7c8c0
refactor(next-swc): remove unused crashreporter (#60593)
<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change



### Why?

### How?

Closes NEXT-
Fixes #

-->

### What?

This code path has not been used for some time and it is clear we won't
use this as-is. Better to get rid of them and reintroduce depends on the
needs.


Closes PACK-2235
2024-01-16 11:01:47 -08:00
Leah
ee6cc6d9c2
feat(turbopack): support named client references properly (#59578)
### What?
Makes sure `import * as mod from 'client-mod'` works properly by
actually adding the exports to the emitted module.

Depends on: https://github.com/vercel/turbo/pull/6787

### Turbopack Updates

* https://github.com/vercel/turbo/pull/6965 <!-- Tobias Koppers -
recycle trace buffers -->
* https://github.com/vercel/turbo/pull/6974 <!-- Chris Olszewski -
feat(lockfiles): support Yarn 4 patches -->
* https://github.com/vercel/turbo/pull/6787 <!-- Leah -
feat(turbopack-ecmascript): support named client references -->


Closes PACK-2110
2024-01-10 18:14:36 +00:00
Tobias Koppers
990d0a9ab8
update turbopack (#60478)
* https://github.com/vercel/turbo/pull/6978 <!-- Tobias Koppers - fix
aggregation of outdated children and collectibles -->
* https://github.com/vercel/turbo/pull/6968 <!-- Tobias Koppers - fix
glob matching of alternatives -->
* https://github.com/vercel/turbo/pull/6922 <!-- Tobias Koppers - avoid
using a write lock for root info -->
2024-01-10 17:45:29 +00:00
Tobias Koppers
45370e8ce8
update turbopack (#60208)
* https://github.com/vercel/turbo/pull/6720 <!-- Tobias Koppers - fix
weird local name, add tests -->
* https://github.com/vercel/turbo/pull/6832 <!-- Leah -
fix(turbopack-ecmascript): make sure async module wrapper is always
generated -->
* ~https://github.com/vercel/turbo/pull/6885~ <!-- Tobias Koppers - fix
aggregation of outdated children and collectibles -->
* ~https://github.com/vercel/turbo/pull/6839 <!-- Tobias Koppers - fix
glob matching of alternatives -->~
* https://github.com/vercel/turbo/pull/6884 <!-- Donny/강동윤 - Update
`swc_core` to `v0.87.16` -->
* https://github.com/vercel/turbo/pull/6964 <!-- Tobias Koppers - Reduce
calls, tasks and duplicate work -->
2024-01-10 11:14:46 +01:00
OJ Kwon
46370d816b
refactor(next/core): reorganize next.js custom transforms for next-swc/turbopack (#60400)
<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change



-->

### What?

This PR refactors organization for the rust side packages to build
`next-swc`.

### Why?

We had some historical legacy around package structures, have ambiguous
name for `core` / `next-core`. One contains swc transform visitor for
the next.js, and the other one is new for turbopack's core next.js
features. In addition to that, there was a package dependency chain
prevents to use `core` in the turobpack / next-swc both, so each time
porting a transformer into turbopack it requires to extract new
dependency to be imported in the both place.

PR touches its organization - while PR is large to touch various files,
the crux is summarized at
2cedd06ea5
:

1. `core` becomes `next-custom-transforms`, also this becomes an
agnostic pkg can be imported in turbopack / wasm / next-swc
2. simplify dependency chain to import next-custom-transforms, organized
as below

```mermaid
flowchart TD
    C(next-custom-transforms) --> A(napi)
    C(next-custom-transforms) --> B(wasm)
    D(next-core) --> A(napi)
    E(next-build) --> A(napi)
    F(next-api) --> A(napi)
    C(next-custom-transforms) --> D
    D(next-core) --> F(next-api)
    D(next-core) --> E(next-build)
```

`impl CustomTransformer` for the each transform still lives in
`next-core`, so turbopack specific dependency is isolated under
`next-core/build/api`.


Closes PACK-2201
Closes PACK-2202

---------

Co-authored-by: hrmny <8845940+ForsakenHarmony@users.noreply.github.com>
2024-01-09 12:23:47 -08:00
Donny/강동윤
1e7e6e1c93
Update swc_core to v0.87.16 (#60192)
### What?

Update swc crates

### Why?

To fix bugs

### How?

Closes PACK-1682
Closes PACK-2154
Fixes #56144

---------

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2024-01-08 14:38:21 +01:00
OJ Kwon
f641d9ccfc
feat(next-core): apply rsc transform in turbopack (#59629)
### What?

Turbopack does not apply same transform for the react server components,
which makes missing lot of compilation error validation and custom
comments. PR refactors transform to be used in next-swc / turbopack
both, then apply it into turbopack.

There are still some of test cases are not passing, might need further
digging for the transform condition.


Closes PACK-2155

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2024-01-05 16:14:06 +01:00
Donny/강동윤
82cd86d66b
Update swc_core to v0.87.10 (#59834)
### What?

Update SWC crates

### Why?

It's required to fix some next.js isssues

### How?

Closes PACK-2174
Turbopack counterpart: https://github.com/vercel/turbo/pull/6843

---


# Turbopack

* https://github.com/vercel/turbo/pull/6737 <!-- Nicholas Yang - feat:
Nice errors for shim flag parsing -->
* https://github.com/vercel/turbo/pull/6494 <!-- Justin Ridgewell -
Trace output's source maps through input's source map -->
* https://github.com/vercel/turbo/pull/6778 <!-- Will Binns-Smith -
turbopack-css: fix rule duplication -->
* https://github.com/vercel/turbo/pull/6807 <!-- Mehul Kar - fix: add
missing dependency to cargo lockfile -->
* https://github.com/vercel/turbo/pull/6809 <!-- Nicholas Yang -
refactor: Remove bookkeeping abstraction from turbo config -->
* https://github.com/vercel/turbo/pull/6838 <!-- Nicholas Yang - fix:
Allow for long symlinks by using append_link -->
* https://github.com/vercel/turbo/pull/6845 <!-- Donny/강동윤 - perf: Use
`&'static str` instead of `String` if possible -->
* https://github.com/vercel/turbo/pull/6843 <!-- Donny/강동윤 - Update
`swc_core` to `v0.87.10` -->
2024-01-02 08:44:46 +00:00
Leah
e9ac616414
chore: update Turbopack (#59589)
### Changes

* https://github.com/vercel/turbo/pull/6777 <!-- Leah -
fix(turbopack-ecmascript-runtime): handle non encoded CSS paths -->
* https://github.com/vercel/turbo/pull/6785 <!-- Tim Neutkens - Ensure
turbopack-trace-server doesn't send message in a loop -->



Closes PACK-2147
2023-12-13 18:25:37 +01:00
Donny/강동윤
d5291fad49
Update swc_core to v0.86.98 and turbopack (#59393)
### What?

Update SWC crates.

### Why?

To fix OOM bug of `inputSourceMap`.

Patch: https://github.com/swc-project/swc/pull/8402

### How?

Closes PACK-2123



# Turbopack updates

* https://github.com/vercel/turbo/pull/6733 <!-- Thomas Knickman -
chore(ignore): exclude rustic-ice files -->
* https://github.com/vercel/turbo/pull/6731 <!-- Leah -
fix(turbopack-ecmascript-runtime): don't use `path.relative` for
absolute paths -->
* https://github.com/vercel/turbo/pull/6745 <!-- Donny/강동윤 - Update
`swc_core` to `v0.86.98` -->
2023-12-08 19:34:02 +09:00
Tobias Koppers
26b8caaa29
Turbopack: switch to a single client components entrypoint (#59352)
### What?

switch turbopack to use a single client components entrypoint for all
client components on a page for development. This aligns it with the
webpack behavior.

### Why?

compiling a separate entrypoint for every client component is pretty
expensive in regards of compilation, chunking, code generation, file
writing and number of requests.

### Turbopack Changes

* https://github.com/vercel/turbo/pull/6713 <!-- Tobias Koppers - use
real emojis -->
* https://github.com/vercel/turbo/pull/6728 <!-- Tobias Koppers - fix
order of reverse topologic iteration -->


Closes PACK-2115
2023-12-08 08:24:08 +01:00
Tobias Koppers
34e9d65d29
update turbopack (#59334)
* https://github.com/vercel/turbo/pull/6716 <!-- Tobias Koppers - add
support for export renaming in side effects optimization -->
* https://github.com/vercel/turbo/pull/6718 <!-- Tobias Koppers - cache
the chunking work -->
2023-12-06 17:20:52 +01:00
Tobias Koppers
0082d54893
side effects optimization (#58972)
### What?

Code update for refactoring in https://github.com/vercel/turbo/pull/6590


Closes PACK-2043
2023-12-06 08:23:46 +00:00
Tobias Koppers
2b473970ef
update turbopack (#59285)
* https://github.com/vercel/turbo/pull/6588 <!-- Leah - ci: remove daily
turbopack next.js integration test workflow -->
* https://github.com/vercel/turbo/pull/6666 <!-- Will Binns-Smith -
Turbopack css: treat `composes` and `@import` as urls when resolving -->
* https://github.com/vercel/turbo/pull/6701 <!-- Tobias Koppers - add
user level tracing -->
* https://github.com/vercel/turbo/pull/6616 <!-- Leah - feat(turbopack):
support "loading" WebAssembly injected as global varables in edge
runtime -->

Closes PACK-2086
2023-12-05 14:06:49 +01:00
Tobias Koppers
669a48cb4d
fix tsconfig alias cycle (#59232)
### What?

fixes https://github.com/vercel/next.js/issues/59195
fixes PACK-450

### Why?

### How?

see https://github.com/vercel/turbo/pull/6687

### Turbopack Changes

* https://github.com/vercel/turbo/pull/6627 <!-- Tobias Koppers - fix
stack trace of errors -->
* https://github.com/vercel/turbo/pull/6646 <!-- OJ Kwon -
fix(turbo-tasks-fs): support unicode segment for glob -->
* https://github.com/vercel/turbo/pull/6672 <!-- OJ Kwon -
fix(ecmascript): dbg assert for the globals -->
* https://github.com/vercel/turbo/pull/6687 <!-- Tobias Koppers - fix
tsconfig alias cycle -->
2023-12-04 10:50:15 +01:00
OJ Kwon
72af59a1c1
build(cargo): bump up turbopack (#59032)
### What?

Bump up turbopack which includes url rewrite related improvements. This makes `test/integration/url` test passes.

Note there are some lacking behavior around edge runtime + url behavior, it is being tracked in PACK-2014.

Closes PACK-2051
2023-11-28 20:42:26 +00:00
OJ Kwon
048ab21f6b
fix(turbopack): treat .mdx as valid ecma asset (#58985)
### What

Pairing with https://github.com/vercel/turbo/pull/6602, enables
ecma-related transform support in mdx. notably fixes test cases in
https://github.com/vercel/next.js/pull/58968 .

With turbopack side fix, still modularize imports are not being applied
as we limite it to .js* extension only. PR expands it to include mdx if
mdx is enabled. PR is failling until turbopack side fix lands.

Closes PACK-2045

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-11-28 13:54:46 +01:00
Tobias Koppers
f1511515fd
Trace server updates (#58694)
### What?

some refactoring updates


Closes PACK-1994
2023-11-27 15:29:41 +01:00
Donny/강동윤
8e6d51f4fa
Update swc_core to v0.86.81 (#58517)
### What?

Update swc crates.

Diff:
09b3003e58...c566b73bfb

### Why?

To fix bugs, and improve minification.

### How?

turbopack counterpart: https://github.com/vercel/turbo/pull/6472

- Closes PACK-1972

- Closes #30802

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-11-27 11:02:25 +01:00
Tobias Koppers
9f69766cfa
Turbopack: enable some node.js builtin in edge runtime (#58850)
### What?

Edge runtime allow additional node.js builtins

see https://github.com/vercel/turbo/pull/6562


Closes PACK-2031

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2023-11-26 19:55:23 +01:00
Tim Neutkens
c3c006d9f0
Upgrade Turbopack (#58859)
* https://github.com/vercel/turbo/pull/6540 
* https://github.com/vercel/turbo/pull/6549 
* https://github.com/vercel/turbo/pull/6554 
* https://github.com/vercel/turbo/pull/6561 
* https://github.com/vercel/turbo/pull/6563 
* https://github.com/vercel/turbo/pull/6562 
* https://github.com/vercel/turbo/pull/6544
2023-11-24 12:33:50 +00:00
Will Binns-Smith
b3914f6175
Turbopack: update to turbopack-231122.3 (#58784)
Includes vercel/turbo#6525
2023-11-22 22:22:26 +01:00
Will Binns-Smith
154268a144
Turbopack: Use styled issue titles and details (#58743)
This uses styled issue titles and details introduced in
vercel/turbo#6535, which also moves "Module not found" messaging to the
title field for those issues.


Closes PACK-2013

---------

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
Co-authored-by: Leah <github.leah@hrmny.sh>
Co-authored-by: Zack Tanner <zacktanner@gmail.com>
2023-11-22 13:39:24 +01:00
Tobias Koppers
3467116794
fix node externals resolving (#58129)
### What?

Various fixes in handling of externals in node.js

* add extensions to builtin externals to allow node.js ESM to work
* improve the auto-externals logic to detect more edge cases
* prepare for `esmExternals` support, but that's blocked by client
manifest missing the async flag
* currently only `esmExternals: false` is supported

### Why?

### Turbopack Changes

* https://github.com/vercel/turbo/pull/6531 <!-- Leah - fix(turbopack):
postcss should be applied to `@import`ed CSS files -->
* https://github.com/vercel/turbo/pull/6530 <!-- Tobias Koppers - fix
node.js externals -->

---------

Co-authored-by: Leah <github.leah@hrmny.sh>
Co-authored-by: Zack Tanner <zacktanner@gmail.com>
2023-11-21 23:58:14 +01:00
Donny/강동윤
94771bf3cc
refactor: Add lightningcss mode for turbopack-css (#58471)
### What?

We are experimenting with `lightningcss`. This is about replacing
`swc_css` with `lightningcss` in turbopack, and the main reason for this
is to reduce the maintenance burden.
But when I tried, it introduced several regressions, so I'm putting it
behind an experimental flag.

You can enable `lightningcss` mode for **turbopack** by adding a flag to
the next config file.

```js
/**
 * @type {import('next').NextConfig}
 */
const nextConfig = {
  experimental: {
    useLightningcss: true,
  },
}

module.exports = nextConfig

```

Note that this is only for turbopack because we were not using `swc_css`
for non-turbopack mode of next.js



x-ref:
https://vercel.slack.com/archives/C03EWR7LGEN/p1700025496732229?thread_ts=1700019629.866549&cid=C03EWR7LGEN


### Why?

We should avoid regressions.

### How?

---

turbopack PR: https://github.com/vercel/turbo/pull/6456


Closes PACK-1966

---------

Co-authored-by: Leah <github.leah@hrmny.sh>
2023-11-20 18:09:36 +01:00
Will Binns-Smith
024a0ef24d
Update rust-toolchain to 2023-11-16 (#58558)
This updates the rust toolchain to 2023-11-16 and:

- Removes now-unnecessary `#![feature(async_fn_in_trait)]`
- Applies auto-fixable lint fixes
- Uses `Cargo.toml` new `lint` section instead of command line rustc flags

Test Plan: Tested with updated turbo in a create-next-app


Closes PACK-1979

Co-authored-by: OJ Kwon <1210596+kwonoj@users.noreply.github.com>
2023-11-18 00:29:50 +00:00