rsnext/packages/next-swc
Wyatt Johnson 03a09ba1e6
Shared Loaders for Webpack and Turbopack (#52846)
This updates the Turbopack build code to provide the same `routeModule` export for App Pages as the Webpack loader does. This also adapts the Turbopack and Webpack loaders to use a shared loader file that is templated.

Fixes NEXT-1469

The template supports the following styles:

# Injections

```ts
declare const tree: LoaderCode
```

Allows you to define the variable in scope in TS, this lets you reference it with correct types within the rest of the file.

```ts
// INJECT:tree
```

Is replaced by the variable that's injected. This lets you ensure the correct invocation/initilization order.

# Variables

Variables will be substituted in the TS code when found. It's only really useful for strings, as the definition looks for the following in the outputted JS code:

```ts
"VAR_REPLACE_ME"
```

So you can have something like:

```ts
const thing = new AmazingThing({ page: "VAR_PAGE" })
```

And it'll be replaced by:

```ts
const thing = new AmazingThing({ page: "/thing" })
```

Where `VAR_PAGE` is `JSON.stringify("/thing")`.
2023-07-31 19:20:04 +00:00
..
crates Shared Loaders for Webpack and Turbopack (#52846) 2023-07-31 19:20:04 +00:00
native Extract next-swc Rust code into its own package (#31635) 2021-11-21 12:59:56 +01:00
package.json v13.4.13-canary.7 2023-07-31 17:31:05 +00:00
README.md docs: add readme with development instructions for next/swc (#43834) 2022-12-08 13:38:44 +01:00

@next/swc

This package is responsible for swc compilation customized for next.js

Development

Run tests

cargo test

# Update snapshots and fixtures for tests
UPDATE=1 cargo test

Format code before submitting code

cargo fmt

Build the binary to integrate with next.js

pnpm build-native