-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement styled-jsx with swc's styled_jsx (vercel/turborepo#354)
This implements support for styled-jsx in next-dev using swc's styled_jsx crate. It's only applied in next-dev, and is only applied as a transform to app code, much like the react-refresh transform. To do: * [x] The transform doesn't seem to be applied. Pass the added test. Test Plan: `cargo test -p next-dev -- test_crates_next_dev_tests_integration_turbopack_basic_styled_jsx --nocapture`
- Loading branch information
1 parent
826998c
commit d4192f4
Showing
4 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
packages/next-swc/crates/next-dev/tests/integration/turbopack/basic/styled-jsx/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React from 'react' | ||
import TestRenderer from 'react-test-renderer' | ||
|
||
describe('styled-jsx', () => { | ||
it('compiles away <style jsx>', () => { | ||
const test = TestRenderer.create( | ||
<> | ||
<span>This should be color: red</span> | ||
<style jsx>{` | ||
span { | ||
color: red; | ||
} | ||
`}</style> | ||
</>, | ||
) | ||
|
||
expect(test.toJSON()).toMatchObject({ | ||
children: ['This should be color: red'], | ||
props: { | ||
className: /jsx\-[0-9a-f]+/, | ||
}, | ||
type: 'span', | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters