Skip to content

Commit

Permalink
Add next font package (#40227)
Browse files Browse the repository at this point in the history
For some context:
https://vercel.slack.com/archives/CGU8HUTUH/p1662124179102509

Adds `@next/font` package.

`scripts/update-google-fonts.js` generates functions and metadata for
all available google fonts. The metadata is used in `loader.ts` to
validate font options (from #40221). It then fetches the CSS from google
fonts, downloads the font files and emits them as static assets.

The actual integration with `packages/next` and integration tests
depends on #40221, will follow up with new PR.

Co-authored-by: JJ Kasper <jj@jjsweb.site>
  • Loading branch information
Hannes Bornö and ijjk committed Sep 21, 2022
1 parent 97b3187 commit 1264196
Show file tree
Hide file tree
Showing 16 changed files with 24,215 additions and 4 deletions.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -63,6 +63,7 @@
"@next/bundle-analyzer": "workspace:*",
"@next/env": "workspace:*",
"@next/eslint-plugin-next": "workspace:*",
"@next/font": "workspace:*",
"@next/mdx": "workspace:*",
"@next/plugin-storybook": "workspace:*",
"@next/polyfill-module": "workspace:*",
Expand Down
3 changes: 3 additions & 0 deletions packages/font/README.md
@@ -0,0 +1,3 @@
# `@next/font`

Experimental `@next/font` package
1 change: 1 addition & 0 deletions packages/font/google/index.d.ts
@@ -0,0 +1 @@
export * from '../dist/google'
1 change: 1 addition & 0 deletions packages/font/google/index.js
@@ -0,0 +1 @@
throw new Error('@next/font/google is not correctly setup')
1 change: 1 addition & 0 deletions packages/font/google/loader.d.ts
@@ -0,0 +1 @@
export { default } from '../dist/google/loader'
1 change: 1 addition & 0 deletions packages/font/google/loader.js
@@ -0,0 +1 @@
module.exports = require('../dist/google/loader')
19 changes: 19 additions & 0 deletions packages/font/package.json
@@ -0,0 +1,19 @@
{
"name": "@next/font",
"version": "12.3.2-canary.0",
"repository": {
"url": "vercel/next.js",
"directory": "packages/font"
},
"files": [
"dist",
"google"
],
"license": "MIT",
"scripts": {
"build": "rm -rf dist && tsc -d -p tsconfig.json",
"prepublishOnly": "cd ../../ && turbo run build",
"dev": "tsc -d -w -p tsconfig.json",
"typescript": "tsec --noEmit -p tsconfig.json"
}
}

0 comments on commit 1264196

Please sign in to comment.