rsnext/packages/next-swc
Hannes Bornö 97b31873e1
next-swc: add next-font-loaders to crates/core (#40221)
For some context:
https://vercel.slack.com/archives/CGU8HUTUH/p1662124179102509

Transforms call expressions of imported functions, only affects imports
specified in SWC options. Each argument is turned into JSON and appended
to the import as a query. The query can be read in a webpack loader,
i.e. the call expression is only evaluated at build time

### Transform
From
```tsx
import { Fn } from "package"
const res = Fn(1, "2", { three: true })
```
To
```tsx
import res from 'package?Fn;1;"2";{"three":true}'
```

### Visitors
#### NextFontLoaders (mod.rs)
Creates several visitors that updates the state and reports errors. This
is where the AST is mutated. After all other visitors are done the call
expressions and original imports are removed. The newly generated
imports are added instead.

#### FontFunctionsCollector
Finds imports from the specified packages. Function calls of these
imports should be transformed.

#### FontImportsGenerator
Creates import declarations, call expression arguments are turned into
JSON and added to the import as a query.

#### FindFunctionsOutsideModuleScope
Makes sure that there's no reference of the functions anywhere else but
the module scope.

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-09-21 13:35:49 -07:00
..
.cargo build(next-swc): linux glibc compatible issue (#34481) 2022-02-18 16:04:43 +00:00
crates next-swc: add next-font-loaders to crates/core (#40221) 2022-09-21 13:35:49 -07:00
native Extract next-swc Rust code into its own package (#31635) 2021-11-21 12:59:56 +01:00
.rustfmt.toml Extract next-swc Rust code into its own package (#31635) 2021-11-21 12:59:56 +01:00
Cargo.lock chore: Update swc (#40520) 2022-09-15 14:22:11 +02:00
Cargo.toml feat(next-swc): Update swc crates (#35395) 2022-03-30 15:13:40 -07:00
package.json v12.3.2-canary.0 2022-09-21 10:50:28 +02:00
rust-toolchain chore: Update swc (#39965) 2022-09-04 12:13:22 +02:00