Skip to content

Commit

Permalink
Update swc_core to v0.96.9 (#67378)
Browse files Browse the repository at this point in the history
# Turbopack
* vercel/turborepo#8686 <!-- Tobias Koppers -
improve performance of the graph aggregation -->
* vercel/turborepo#8694 <!-- Benjamin Woodruff -
Replace `unreachable` with `bail` in `finalize_css` -->
* vercel/turborepo#8661 <!-- Benjamin Woodruff -
Create a minimum viable `ResolvedVc` type -->
* vercel/turborepo#8662 <!-- Benjamin Woodruff - Add
a minimum viable ResolvedValue marker trait -->
* vercel/turborepo#8678 <!-- Benjamin Woodruff - Add
derive macro for ResolvedValue -->
* vercel/turborepo#8715 <!-- Benjamin Woodruff -
Switch RcStr from std::sync::Arc to triomphe::Arc -->
* vercel/turborepo#8699 <!-- Donny/강동윤 - perf: Merge
multiple `EsmBinding` -->
* vercel/turborepo#8720 <!-- Benjamin Woodruff - Add
support for `#[turbo_tasks::value(resolved)]` and
`#[turbo_tasks::value_trait(resolved)]` -->
* vercel/turborepo#8706 <!-- Donny/강동윤 - build:
Update `swc_core` to `v0.96.9` -->

### What?

Update SWC crates to
swc-project/swc@226617e
and
swc-project/plugins@b7658c3

### Why?

To keep in sync

### How?

 - Closes #64890
 - Closes #63104
  • Loading branch information
kdy1 authored Jul 12, 2024
1 parent ce90960 commit 8063a51
Show file tree
Hide file tree
Showing 72 changed files with 446 additions and 620 deletions.
425 changes: 178 additions & 247 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ next-core = { path = "packages/next-swc/crates/next-core" }
next-custom-transforms = { path = "packages/next-swc/crates/next-custom-transforms" }

# SWC crates
swc_core = { version = "0.95.4", features = [
swc_core = { version = "0.96.9", features = [
"ecma_loader_lru",
"ecma_loader_parking_lot",
] }
testing = { version = "0.36.0" }

# Turbo crates
turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240704.3" }
turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240712.1" }
# [TODO]: need to refactor embed_directory! macro usages, as well as resolving turbo_tasks::function, macros..
turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240704.3" }
turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240712.1" }
# [TODO]: need to refactor embed_directory! macro usage in next-core
turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240704.3" }
turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240712.1" }

# General Deps

Expand Down
1 change: 1 addition & 0 deletions packages/next-swc/crates/napi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ tracing-subscriber = { workspace = true }
tracing-chrome = "0.5.0"
url = { workspace = true }
urlencoding = { workspace = true }
once_cell ={workspace= true}

# Dependencies for the native, non-wasm32 build.
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
Expand Down
18 changes: 16 additions & 2 deletions packages/next-swc/crates/napi/src/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ use anyhow::{anyhow, bail, Context as _};
use fxhash::FxHashSet;
use napi::bindgen_prelude::*;
use next_custom_transforms::chain_transforms::{custom_before_pass, TransformOptions};
use once_cell::sync::Lazy;
use turbopack_binding::swc::core::{
base::{try_with_handler, Compiler, TransformOutput},
common::{comments::SingleThreadedComments, errors::ColorConfig, FileName, Mark, GLOBALS},
Expand All @@ -61,9 +62,22 @@ pub struct TransformTask {
pub options: Buffer,
}

#[inline]
fn skip_filename() -> bool {
cfg!(debug_assertions)
fn check(name: &str) -> bool {
let v = std::env::var(name);
let v = match v {
Ok(v) => v,
Err(_) => return false,
};

!v.is_empty() && v != "0"
}

static SKIP_FILENAME: Lazy<bool> = Lazy::new(|| {
check("NEXT_TEST_MODE") || check("__NEXT_TEST_MODE") || check("NEXT_TEST_JOB")
});

*SKIP_FILENAME
}

impl Task for TransformTask {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ impl ModularizeImportsTransformer {
},
prevent_full_import: v.prevent_full_import,
skip_default_conversion: v.skip_default_conversion,
handle_default_import: false,
handle_namespace_import: false,
},
)
})
Expand Down
6 changes: 3 additions & 3 deletions packages/next-swc/crates/next-custom-transforms/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ turbopack-binding = { workspace = true, features = [
] }
# To allow quote! macro works
swc_core = { workspace = true, features = ["ecma_quote"] }
react_remove_properties = "0.24.14"
remove_console = "0.25.14"
preset_env_base = "0.4.12"
react_remove_properties = "0.24.15"
remove_console = "0.25.15"
preset_env_base = "0.5.1"

[dev-dependencies]
turbopack-binding = { workspace = true, features = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ where
let relay_plugin = {
if let Some(config) = &opts.relay {
Either::Left(turbopack_binding::swc::custom_transform::relay::relay(
config,
Arc::new(config.clone()),
file.name.clone(),
std::env::current_dir().unwrap(),
opts.pages_dir.clone(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ mod tests {
common::{errors::ColorConfig, FilePathMapping, SourceMap, GLOBALS},
ecma::{
ast::Program,
parser::{EsConfig, Syntax, TsConfig},
parser::{EsSyntax, Syntax, TsSyntax},
},
};

Expand All @@ -247,13 +247,13 @@ mod tests {
let options = ParseOptions {
is_module: IsModule::Unknown,
syntax: if file_path.ends_with(".ts") || file_path.ends_with(".tsx") {
Syntax::Typescript(TsConfig {
Syntax::Typescript(TsSyntax {
tsx: true,
decorators: true,
..Default::default()
})
} else {
Syntax::Es(EsConfig {
Syntax::Es(EsSyntax {
jsx: true,
decorators: true,
..Default::default()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use turbopack_binding::swc::{
core::{
common::{chain, FileName, Mark},
ecma::{
parser::{EsConfig, Syntax},
parser::{EsSyntax, Syntax},
transforms::{
base::resolver,
testing::{test_fixture, FixtureTestConfig},
Expand All @@ -26,7 +26,7 @@ use turbopack_binding::swc::{
};

fn syntax() -> Syntax {
Syntax::Es(EsConfig {
Syntax::Es(EsSyntax {
jsx: true,
..Default::default()
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

x next/dynamic requires at least one argument
,-[input.js:2:1]
,-[input.js:3:1]
2 |
3 | const DynamicComponent = dynamic()
: ^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

x next/dynamic options must be an object literal.
| Read more: https://nextjs.org/docs/messages/invalid-dynamic-options-type
,-[input.js:3:1]
,-[input.js:4:1]
3 | const options = { loading: () => <p>...</p>, ssr: false }
4 | const DynamicComponentWithCustomLoading = dynamic(
: ^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

x next/dynamic only accepts 2 arguments
,-[input.js:2:1]
,-[input.js:3:1]
2 |
3 | const DynamicComponentWithCustomLoading = dynamic(
: ^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@

x Font loader calls must be assigned to a const
,-[input.js:3:1]
,-[input.js:4:1]
3 |
4 | export let firaCode = Abel()
: ^^^^^^^^^^^^^^^^^^^^^
5 | export var inter = Inter()
`----

x Font loader calls must be assigned to a const
,-[input.js:4:1]
,-[input.js:5:1]
4 | export let firaCode = Abel()
5 | export var inter = Inter()
: ^^^^^^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

x Font loaders can't have namespace imports
,-[input.js:1:1]
1 | import * as googleFonts from '@next/font/google'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@

x Font loader calls must be assigned to a const
,-[input.js:3:1]
,-[input.js:4:1]
3 | var i = 10
4 | ,-> var inter1 = Inter({
5 | | variant: '400',
6 | `-> })
`----

x Font loader calls must be assigned to a const
,-[input.js:8:1]
,-[input.js:9:1]
8 | var i2 = 20
9 | ,-> let inter2 = Inter({
10 | | variant: '400',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@

x Font loader calls must be assigned to an identifier
,-[input.js:2:1]
,-[input.js:3:1]
2 |
3 | const { a } = Inter({
: ^^^^^
4 | variant: '400',
`----

x Font loader calls must be assigned to an identifier
,-[input.js:6:1]
,-[input.js:7:1]
6 |
7 | const [b] = Inter({
: ^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@

x Unexpected object key type
,-[input.js:3:1]
,-[input.js:4:1]
3 | const a = fn({ 10: 'hello' })
4 | const a = ABeeZee({ 10: 'hello' })
: ^^
`----

x Font loader values must be explicitly written literals.
,-[input.js:6:1]
,-[input.js:7:1]
6 | const a = fn({ variant: [i1] })
7 | const a = ABeeZee({ variant: [i1] })
: ^^
`----

x Font loader values must be explicitly written literals.
,-[input.js:9:1]
,-[input.js:10:1]
9 | const a = fn({ variant: () => {} })
10 | const a = ABeeZee({ variant: () => {} })
: ^^^^^^^^
`----

x Unexpected spread
,-[input.js:12:1]
,-[input.js:13:1]
12 | const a = fn({ ...{} })
13 | const a = ABeeZee({ ...{} })
: ^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@

x Font loaders don't accept spreads
,-[input.js:3:1]
,-[input.js:4:1]
3 | const a = fn(...{}, ...[])
4 | const inter = Inter(...{}, ...[])
: ^^^
`----

x Font loaders don't accept spreads
,-[input.js:3:1]
,-[input.js:4:1]
3 | const a = fn(...{}, ...[])
4 | const inter = Inter(...{}, ...[])
: ^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,31 @@

x Font loaders must be called and assigned to a const in the module scope
,-[input.js:2:1]
,-[input.js:3:1]
2 |
3 | Aladin({})
: ^^^^^^
`----

x Font loaders must be called and assigned to a const in the module scope
,-[input.js:5:1]
,-[input.js:6:1]
5 | let b
6 | const a = (b = Aladin({ variant: '400' }))
: ^^^^^^
`----

x Font loaders must be called and assigned to a const in the module scope
,-[input.js:8:1]
,-[input.js:9:1]
8 | function Hello() {
9 | const a = Aladin({
: ^^^^^^
10 | variant: '400',
`----

x Font loaders must be called and assigned to a const in the module scope
,-[input.js:15:1]
,-[input.js:16:1]
15 | constructor() {
16 | Aladin({
: ^^^^^^
17 | variant: '400',
`----

x Font loaders must be called and assigned to a const in the module scope
,-[input.js:22:1]
,-[input.js:23:1]
22 | {
23 | Aladin({})
: ^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

x You can not use getStaticProps or getStaticPaths with getServerSideProps. To use SSG, please remove getServerSideProps
,-[input.js:1:1]
,-[input.js:2:1]
1 | export async function getStaticPaths() {}
2 | export const getServerSideProps = function getServerSideProps() {}
: ^^^^^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

x You can not use getStaticProps or getStaticPaths with getServerSideProps. To use SSG, please remove getServerSideProps
,-[input.js:1:1]
,-[input.js:2:1]
1 | const getStaticProps = async () => {}
2 | export { a as getServerSideProps }
: ^^^^^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

x You can not use getStaticProps or getStaticPaths with getServerSideProps. To use SSG, please remove getServerSideProps
,-[input.js:1:1]
,-[input.js:2:1]
1 | export { a as getServerSideProps } from './input'
2 | export { getStaticPaths } from 'a'
: ^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

x You can not use getStaticProps or getStaticPaths with getServerSideProps. To use SSG, please remove getServerSideProps
,-[input.js:1:1]
1 | export { getStaticProps, getServerSideProps }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

x Using `export * from '...'` in a page is disallowed. Please use `export { default } from '...'` instead.
| Read more: https://nextjs.org/docs/messages/export-all-in-page
,-[input.js:1:1]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

x "getServerSideProps" is not supported in app/. Read more: https://nextjs.org/docs/app/building-your-application/data-fetching
|
|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

x "getStaticProps" is not supported in app/. Read more: https://nextjs.org/docs/app/building-your-application/data-fetching
|
|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@

x You're importing a component that needs "server-only". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/getting-started/
| react-essentials#server-components
|
|
,-[input.js:8:1]
,-[input.js:9:1]
8 |
9 | import 'server-only'
: ^^^^^^^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

x The "use client" directive must be placed before other expressions. Move it to the top of the file to resolve this issue.
,-[input.js:3:1]
,-[input.js:4:1]
3 | // prettier-ignore
4 | 'use client'
: ^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

x You're importing a component that imports client-only. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default.\nLearn
| more: https://nextjs.org/docs/getting-started/react-essentials\n\n
,-[input.js:8:1]
,-[input.js:9:1]
8 |
9 | import 'client-only'
: ^^^^^^^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

x The "use client" directive must be placed before other expressions. Move it to the top of the file to resolve this issue.
,-[input.js:5:1]
,-[input.js:6:1]
5 | // prettier-ignore
6 | 'use client'
: ^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

x "getServerSideProps" is not supported in app/. Read more: https://nextjs.org/docs/app/building-your-application/data-fetching
|
|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

x "getStaticProps" is not supported in app/. Read more: https://nextjs.org/docs/app/building-your-application/data-fetching
|
|
Expand Down
Loading

0 comments on commit 8063a51

Please sign in to comment.