Skip to content

Commit d44d0f0

Browse files
committed
docs(compiler): add description
1 parent e77590b commit d44d0f0

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

docs/advanced-features/compiler.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,42 @@ This transform uses [handlebars](https://docs.rs/handlebars) to template the rep
316316
2. `member`: Has type `string`. The name of the member import.
317317
3. `lowerCase`, `upperCase`, `camelCase`: Helper functions to convert a string to lower, upper or camel cases.
318318

319+
### SWC Trace profiling
320+
321+
You can generate SWC's internal transform traces as chromium's [trace event format](https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview?mode=html#%21=).
322+
323+
```js
324+
// next.config.js
325+
326+
module.exports = {
327+
experimental: {
328+
swcTraceProfiling: true,
329+
},
330+
}
331+
```
332+
333+
Once enabled, swc will generate trace named as `swc-trace-profile-${timestamp}.json` under `.next/`. Chromium's trace viewer (chrome://tracing/, https://ui.perfetto.dev/), or compatible flamegraph viewer (https://www.speedscope.app/) can load & visualize generated traces.
334+
335+
### Experimental SWC plugin support
336+
337+
You can configure swc's transform to use SWC's experimental plugin support written in wasm to customize transformation behavior.
338+
339+
```js
340+
// next.config.js
341+
342+
module.exports = {
343+
experimental: {
344+
swcPlugins: [
345+
['plugin', {
346+
..pluginOptions
347+
}]
348+
]
349+
}
350+
}
351+
```
352+
353+
`swcPlugins` accepts an array of tuple for configuring plugins. A tuple for the plugin contains path to the plugin, and an object for its configurations. Path to the plugin can be a npm module package name, or absolute path to the `.wasm` binary itself.
354+
319355
## Unsupported Features
320356

321357
When your application has a `.babelrc` file, Next.js will automatically fall back to using Babel for transforming individual files. This ensures backwards compatibility with existing applications that leverage custom Babel plugins.

0 commit comments

Comments
 (0)