Skip to content

Commit

Permalink
Merge branch 'canary' into update-rsc-refresh-doc-typing
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Mar 24, 2022
2 parents 0a996ba + f16ee05 commit 5abd6c9
Show file tree
Hide file tree
Showing 25 changed files with 1,204 additions and 290 deletions.
2 changes: 1 addition & 1 deletion docs/api-reference/data-fetching/get-static-props.md
Expand Up @@ -85,7 +85,7 @@ Learn more about [Incremental Static Regeneration](/docs/basic-features/data-fet

### `notFound`

The `notFound` boolean allows the page to return a `404` status and [404 Page](/docs/advanced-features/custom-error-page.md#404-page). With `notFound: true`, the page will return a `404` even if there was a successfully generated page before. This is meant to support use cases like user-generated content getting removed by its author.
The `notFound` boolean allows the page to return a `404` status and [404 Page](/docs/advanced-features/custom-error-page.md#404-page). With `notFound: true`, the page will return a `404` even if there was a successfully generated page before. This is meant to support use cases like user-generated content getting removed by its author. Note, `notFound` follows the same `revalidate` behavior [described here](/docs/api-reference/data-fetching/get-static-props.md#revalidate)

```js
export async function getStaticProps(context) {
Expand Down
2 changes: 1 addition & 1 deletion docs/api-reference/next.config.js/rewrites.md
Expand Up @@ -323,7 +323,7 @@ module.exports = {
}
```

If you're using `trailingSlash: true`, you also need to insert a trailing slash in the `source` paramater. If the destination server is also expecting a trailing slash it should be included in the `destination` parameter as well.
If you're using `trailingSlash: true`, you also need to insert a trailing slash in the `source` parameter. If the destination server is also expecting a trailing slash it should be included in the `destination` parameter as well.

```js
module.exports = {
Expand Down
2 changes: 1 addition & 1 deletion docs/basic-features/script.md
Expand Up @@ -166,7 +166,7 @@ There are a number of trade-offs that need to be considered when loading a third

Although the `worker` strategy does not require any additional configuration to work, Partytown supports the use of a config object to modify some of its settings, including enabling `debug` mode and forwarding events and triggers.

If you would like to add additonal configuration options, you can include it within the `<Head />` component used in a [custom `_document.js`](/docs/advanced-features/custom-document.md):
If you would like to add additional configuration options, you can include it within the `<Head />` component used in a [custom `_document.js`](/docs/advanced-features/custom-document.md):

```jsx
import { Html, Head, Main, NextScript } from 'next/document'
Expand Down
13 changes: 12 additions & 1 deletion examples/with-emotion-swc/pages/index.js
@@ -1,5 +1,13 @@
import { css } from '@emotion/react'
import { Animated, Basic, bounce, Combined, Pink } from '../shared/styles'
import {
Animated,
Basic,
bounce,
Combined,
Pink,
BasicExtended,
ComponentSelectorsExtended,
} from '../shared/styles'

const Home = () => (
<div
Expand All @@ -14,6 +22,9 @@ const Home = () => (
With <code>:hover</code>.
</Combined>
<Animated animation={bounce}>Let's bounce.</Animated>
<ComponentSelectorsExtended>
<BasicExtended>Nested</BasicExtended>
</ComponentSelectorsExtended>
</div>
)

Expand Down
11 changes: 10 additions & 1 deletion examples/with-emotion-swc/shared/styles.js
Expand Up @@ -58,10 +58,19 @@ export const Combined = styled.div`
}
`

export const Pink = styled.div(basicStyles, {
export const Pink = styled(Basic)({
color: 'hotpink',
})

export const BasicExtended = styled(Basic)``

export const ComponentSelectorsExtended = styled.div`
${BasicExtended} {
color: green;
}
box-shadow: -5px -5px 0 0 green;
`

export const Animated = styled.div`
${basicStyles};
${hoverStyles};
Expand Down
30 changes: 19 additions & 11 deletions packages/next-swc/crates/core/src/emotion/mod.rs
Expand Up @@ -442,7 +442,7 @@ impl<C: Comments> Fold for EmotionTransformer<C> {
)));
}
if let Some(cm) = self.create_sourcemap(expr.span.lo()) {
c.args.push(cm.as_arg());
expr.args.push(cm.as_arg());
}
c.args.push(
Expr::Object(ObjectLit {
Expand Down Expand Up @@ -489,7 +489,7 @@ impl<C: Comments> Fold for EmotionTransformer<C> {
);
if let Some(cm) = self.create_sourcemap(expr.span.lo())
{
args.push(cm.as_arg());
expr.args.push(cm.as_arg());
}
}
return CallExpr {
Expand Down Expand Up @@ -556,9 +556,7 @@ impl<C: Comments> Fold for EmotionTransformer<C> {
}),
)));
}
if let Some(cm) = self.create_sourcemap(call.span.lo()) {
callee.args.push(cm.as_arg());
}

callee.args.push(
Expr::Object(ObjectLit {
span: DUMMY_SP,
Expand All @@ -569,11 +567,19 @@ impl<C: Comments> Fold for EmotionTransformer<C> {
return Expr::Call(CallExpr {
span: DUMMY_SP,
callee: callee.as_callee(),
args: self
.create_args_from_tagged_tpl(&mut tagged_tpl.tpl)
.into_iter()
.map(|exp| exp.fold_children_with(self))
.collect(),
args: {
let mut args: Vec<ExprOrSpread> = self
.create_args_from_tagged_tpl(&mut tagged_tpl.tpl)
.into_iter()
.map(|exp| exp.fold_children_with(self))
.collect();
if let Some(cm) =
self.create_sourcemap(tagged_tpl.span.lo())
{
args.push(cm.as_arg());
}
args
},
type_args: None,
});
}
Expand Down Expand Up @@ -626,11 +632,13 @@ impl<C: Comments> Fold for EmotionTransformer<C> {
}
let mut args =
self.create_args_from_tagged_tpl(&mut tagged_tpl.tpl);

if let Some(cm) =
self.create_sourcemap(member_expr.span.lo())
self.create_sourcemap(tagged_tpl.span.lo())
{
args.push(cm.as_arg());
}

self.comments.add_pure_comment(member_expr.span.lo());
return Expr::Call(CallExpr {
span: DUMMY_SP,
Expand Down
Expand Up @@ -32,6 +32,9 @@ const SpanContainer = styled('span')({
background: 'yellow',
})

export const DivContainerExtended = styled(DivContainer)``
export const DivContainerExtended2 = styled(DivContainer)({})

const Container = styled('button')`
background: red;
${stylesInCallback}
Expand Down

0 comments on commit 5abd6c9

Please sign in to comment.