rsnext/packages
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
..
create-next-app v12.3.2-canary.0 2022-09-21 10:50:28 +02:00
eslint-config-next v12.3.2-canary.0 2022-09-21 10:50:28 +02:00
eslint-plugin-next v12.3.2-canary.0 2022-09-21 10:50:28 +02:00
next Remove unnecessary experimental flag (#40766) 2022-09-21 21:30:46 +02:00
next-bundle-analyzer v12.3.2-canary.0 2022-09-21 10:50:28 +02:00
next-codemod v12.3.2-canary.0 2022-09-21 10:50:28 +02:00
next-env v12.3.2-canary.0 2022-09-21 10:50:28 +02:00
next-mdx v12.3.2-canary.0 2022-09-21 10:50:28 +02:00
next-plugin-storybook v12.3.2-canary.0 2022-09-21 10:50:28 +02:00
next-polyfill-module v12.3.2-canary.0 2022-09-21 10:50:28 +02:00
next-polyfill-nomodule v12.3.2-canary.0 2022-09-21 10:50:28 +02:00
next-swc next-swc: add next-font-loaders to crates/core (#40221) 2022-09-21 13:35:49 -07:00
react-dev-overlay v12.3.2-canary.0 2022-09-21 10:50:28 +02:00
react-refresh-utils v12.3.2-canary.0 2022-09-21 10:50:28 +02:00