Skip to content

Commit

Permalink
[6/n] @next/font/google: Cache stylesheet locally (#2940)
Browse files Browse the repository at this point in the history
* Add font-data.json

* Initial implementation of dynamic ImportMapping replacement

* Extract font urls

* Download fonts

* Update stylesheet

* Vc-ify

* Apply suggestions from code review

Co-authored-by: Alex Kirszenberg <alex.kirszenberg@vercel.com>

* Check in font-data.json update script and update font-data.json

* Add font update to ci schedule

* assert -> bail

* Remove extraction and caching of fonts

Co-authored-by: Alex Kirszenberg <alex.kirszenberg@vercel.com>
  • Loading branch information
wbinnssmith and alexkirsz committed Dec 8, 2022
1 parent ec822a5 commit cd4a9f2
Show file tree
Hide file tree
Showing 16 changed files with 18,078 additions and 32 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/update-google-fonts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Update Google font-data.json

on:
schedule:
- cron: "15 0 * * *" # Run every day at 00:15
workflow_dispatch:

jobs:
update_font_data:
name: Update Google font-data.json
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: node ./scripts/fetch-google-font-data.js > crates/next-core/src/next_font_google/__generated__/font-data.json
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Update Google font-data.json (${{ github.sha }})
file_pattern: crates/next-core/src/next_font_google/__generated__/font-data.json
6 changes: 6 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions crates/next-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,19 @@ bench = false

[dependencies]
anyhow = "1.0.47"
auto-hash-map = { path = "../auto-hash-map" }
indexmap = { workspace = true, features = ["serde"] }
indoc = "1.0"
mime = "0.3.16"
once_cell = "1.13.0"
qstring = "0.7.2"
serde = "1.0.136"
serde_json = "1.0.85"
turbo-tasks = { path = "../turbo-tasks" }
turbo-tasks-env = { path = "../turbo-tasks-env" }
turbo-tasks-fetch = { path = "../turbo-tasks-fetch" }
turbo-tasks-fs = { path = "../turbo-tasks-fs" }
turbo-tasks-hash = { path = "../turbo-tasks-hash" }
turbopack = { path = "../turbopack" }
turbopack-core = { path = "../turbopack-core" }
turbopack-dev-server = { path = "../turbopack-dev-server" }
Expand Down
3 changes: 1 addition & 2 deletions crates/next-core/src/fallback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use turbopack_core::{
use turbopack_dev_server::html::DevHtmlAssetVc;

use crate::{
embed_js::attached_next_js_package_path,
next_client::context::{
get_client_chunking_context, get_client_environment, get_client_module_options_context,
get_client_resolve_options_context, get_client_runtime_entries, ContextType,
Expand All @@ -39,7 +38,7 @@ pub async fn get_fallback_page(
let entries = get_client_runtime_entries(project_root, env, ty);

let mut import_map = ImportMap::empty();
insert_next_shared_aliases(&mut import_map, attached_next_js_package_path(project_root));
insert_next_shared_aliases(&mut import_map, project_root);

let context: AssetContextVc = ModuleAssetContextVc::new(
TransitionsByNameVc::cell(HashMap::new()),
Expand Down
1 change: 1 addition & 0 deletions crates/next-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub use web_entry_source::create_web_entry_source;
pub fn register() {
turbo_tasks::register();
turbo_tasks_fs::register();
turbo_tasks_fetch::register();
turbopack_dev_server::register();
turbopack::register();
turbopack_node::register();
Expand Down
Loading

1 comment on commit cd4a9f2

@vercel
Copy link

@vercel vercel bot commented on cd4a9f2 Dec 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.