rsnext/scripts
Hannes Bornö 5f2c9d0b30
Update subset validation in @next/font/google and fix CJK bug (#44594)
Currently there's a bug when selecting Chinese, Japanese or Korean (CJK)
as subsets.
```js
const notoSans = Noto_Sans_JP({
  subsets: ['japanese'],
})
```
It actually doesn't work, nothing preloads. This PR solves this by
removing CJK languages as candidates for preloading. The reason is that
they contain so many glyphs that each font-family is split up in 100+
font files. It doesn't make sense to preload all of them.

So CJK users will have to disable preloading.
```js
const notoSansJapanese = Noto_Sans_JP({
  weight: '400',
  preload: false,
})
```
In case you do manually disable preloading like above, the default
`font-display` is changed to `swap`.

This PR also improves the validation errors of subsets.
1. Providing unknown subset
```
`@next/font` error:
Unknown subset `japanese` for font `Inter`.
Available subsets: `cyrillic`, `cyrillic-ext`, `greek`, `greek-ext`, `latin`, `latin-ext`, `vietnamese`
```
2. Missing specified subset. The error has a link with further
instructions.
```
`@next/font` error:
Missing selected subsets for font `Inter`. Please specify subsets in the function call or in your `next.config.js`. Read more: https://nextjs.org/docs/messages/google-fonts-missing-subsets
```

fixes NEXT-336

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ]
[e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
2023-01-05 15:51:38 -08:00
..
send-trace-to-jaeger Simplify trace span id generation (#32946) 2022-01-02 21:22:01 +00:00
check-examples.sh Add ci script to check examples (#28009) 2021-08-14 13:34:40 -05:00
check-is-release.js Apply publish step optimizations (#43620) 2022-12-01 21:48:51 -08:00
check-manifests.js Changed data fetching file name to overview to fix meta data title (#33232) 2022-01-27 09:14:14 -06:00
check-pre-compiled.bat fixes to allow lazy compilation for import() (#32441) 2021-12-14 11:33:04 +01:00
check-pre-compiled.sh Move core files to src folder and move JS files to TypeScript (#44405) 2023-01-03 10:05:50 +01:00
install-native.mjs Update install native script (#37354) 2022-06-01 09:25:08 -05:00
next-with-deps.sh fix: loosen webpack compilation with fallbackNodePolyfills: false (#40612) 2022-09-16 13:23:56 -07:00
normalize-version-bump.js Avoid turbo cache miss on root package change (#43309) 2022-11-23 15:32:35 -08:00
publish-native.js Apply publish step optimizations (#43620) 2022-12-01 21:48:51 -08:00
publish-release.js Apply publish step optimizations (#43620) 2022-12-01 21:48:51 -08:00
pull-freebsd-cache.js Update caching for swc turbo builds (#42929) 2022-11-15 08:24:04 -08:00
release-stats.sh Apply publish step optimizations (#43620) 2022-12-01 21:48:51 -08:00
reset-vercel-project.mjs Enable E2E deploy tests on publish (#37019) 2022-05-21 04:46:16 -05:00
run-for-change.js Update CNA tests running (#44577) 2023-01-04 15:10:46 -08:00
setup-wasm.mjs Make setup-wasm script work for local dev (#36355) 2022-04-21 15:41:48 -05:00
trace-dd.mjs fix: scripts comment typos (#40207) 2022-09-05 02:26:54 +00:00
trace-next-server.js Add tracing for testing tools (#44046) 2022-12-16 09:58:04 +01:00
trace-to-event-format.mjs fix: scripts comment typos (#40207) 2022-09-05 02:26:54 +00:00
trace-to-tree.mjs Add path to export-page (#39893) 2022-08-24 10:29:47 +00:00
update-google-fonts.js Update subset validation in @next/font/google and fix CJK bug (#44594) 2023-01-05 15:51:38 -08:00