Skip to content

Commit

Permalink
doc: Add docs for relay and styled-components (swc-project#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
damassi authored Jul 27, 2022
1 parent 0586355 commit e2204dc
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 2 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
# plugins
Plugins for swc, written in rust
# Plugins

Plugins for SWC, written in Rust

#### Currently Available:

- [`emotion`](packages/emotion)
- [`jest`](packages/jest)
- [`relay`](packages/relay)
- [`styled-components`](packages/styled-components)
- [`styled-jsx`](packages/styled-jsx)
- [`transform-imports`](packages/transform-imports)
68 changes: 68 additions & 0 deletions packages/relay/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
### `@swc/plugin-relay`

#### Setup

```sh
npm install --save-dev @swc/plugin-relay @swc/[email protected]
```

> @swc/core@1.2.215 is required for now
### Example

The below shows how to configure `@swc/plugin-relay` and pass the options to Webpack:

Create an `.swcrc.js` file like the below:

```js
// .swcrc.js

module.exports = {
jsc: {
experimental: {
plugins: [
[
"@swc/plugin-relay",
{
language: "typescript",
schema: "data/schema.graphql",
rootDir: __dirname,
src: "src",
artifactDirectory: "src/__generated__",
},
],
],
},
parser: {
syntax: "typescript",
tsx: true,
},
transform: {
react: {
runtime: "automatic",
},
},
},
};
```

And then update your `swc-loader` Webpack config:

```js
const swcConfig = require("./.swcrc.js")

// ...

{
include: path.resolve("./src"),
test: /\.ts$/,
use: [
{
loader: "swc-loader",
options: swcConfig,
},
],
}
```

> Note: We're using a `.swcrc.js` file extension up above and importing the config directly because Relay needs access to `__dirname`, which can't be derived from the default JSON parsed from `.swcrc`.
29 changes: 29 additions & 0 deletions packages/styled-components/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
### `@swc/plugin-styled-components`

#### Setup

```sh
npm install --save-dev @swc/plugin-styled-components @swc/[email protected]
```

> @swc/core@1.2.215 is required for now
Then update your `.swcrc` file like below:

```json
{
"jsc": {
"experimental": {
"plugins": [
[
"@swc/plugin-styled-components",
{
"displayName": true,
"ssr": true
}
]
]
}
}
}
```

0 comments on commit e2204dc

Please sign in to comment.