From f9f2f0d27a823208418845e672ed0c62f46e148e Mon Sep 17 00:00:00 2001 From: Vicente Canales Date: Wed, 13 Sep 2023 16:58:16 -0300 Subject: [PATCH] Deps: use lib-font as an npm dependency This changed required applying a change in the webpack config suggested by lib-font's developer, detailed [here](https://github.com/Pomax/lib-font/#how-do-i-use-this-with-webpack). Closes https://github.com/WordPress/gutenberg/issues/53653 --- package-lock.json | 12 ++++++++++++ packages/edit-site/package.json | 1 + .../global-styles/font-library-modal/local-fonts.js | 5 ++++- tools/webpack/packages.js | 6 ++++++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index c2843123b40dcc..69c0f95b096206 100644 --- a/package-lock.json +++ b/package-lock.json @@ -37128,6 +37128,11 @@ "node": ">= 0.8.0" } }, + "node_modules/lib-font": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/lib-font/-/lib-font-2.4.0.tgz", + "integrity": "sha512-j2Hyn12JjMLe9JkFDRq40q4+tOeDg276Z9Ezxyhas8HEv0jNLbRXyzG7r7n6QdLbWRtL2RYQtgVlIt3Q4ur6nQ==" + }, "node_modules/lib0": { "version": "0.2.79", "resolved": "https://registry.npmjs.org/lib0/-/lib0-0.2.79.tgz", @@ -55401,6 +55406,7 @@ "downloadjs": "^1.4.7", "fast-deep-equal": "^3.1.3", "is-plain-object": "^5.0.0", + "lib-font": "2.4.0", "memize": "^2.1.0", "react-autosize-textarea": "^7.1.0", "rememo": "^4.0.2", @@ -68175,6 +68181,7 @@ "downloadjs": "^1.4.7", "fast-deep-equal": "^3.1.3", "is-plain-object": "^5.0.0", + "lib-font": "2.4.0", "memize": "^2.1.0", "react-autosize-textarea": "^7.1.0", "rememo": "^4.0.2", @@ -86994,6 +87001,11 @@ "type-check": "~0.3.2" } }, + "lib-font": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/lib-font/-/lib-font-2.4.0.tgz", + "integrity": "sha512-j2Hyn12JjMLe9JkFDRq40q4+tOeDg276Z9Ezxyhas8HEv0jNLbRXyzG7r7n6QdLbWRtL2RYQtgVlIt3Q4ur6nQ==" + }, "lib0": { "version": "0.2.79", "resolved": "https://registry.npmjs.org/lib0/-/lib0-0.2.79.tgz", diff --git a/packages/edit-site/package.json b/packages/edit-site/package.json index a74742def329cf..927b4261ce6471 100644 --- a/packages/edit-site/package.json +++ b/packages/edit-site/package.json @@ -72,6 +72,7 @@ "downloadjs": "^1.4.7", "fast-deep-equal": "^3.1.3", "is-plain-object": "^5.0.0", + "lib-font": "2.4.0", "memize": "^2.1.0", "react-autosize-textarea": "^7.1.0", "rememo": "^4.0.2", diff --git a/packages/edit-site/src/components/global-styles/font-library-modal/local-fonts.js b/packages/edit-site/src/components/global-styles/font-library-modal/local-fonts.js index 7d5f7a2f79b169..25d4a780f7be32 100644 --- a/packages/edit-site/src/components/global-styles/font-library-modal/local-fonts.js +++ b/packages/edit-site/src/components/global-styles/font-library-modal/local-fonts.js @@ -16,9 +16,12 @@ import { useContext } from '@wordpress/element'; */ import { ALLOWED_FILE_EXTENSIONS } from './utils/constants'; import { FontLibraryContext } from './context'; -import { Font } from '../../../../lib/lib-font.browser'; import makeFamiliesFromFaces from './utils/make-families-from-faces'; import { loadFontFaceInBrowser } from './utils'; +/** + * External dependencies + */ +import { Font } from 'lib-font'; function LocalFonts() { const { installFonts } = useContext( FontLibraryContext ); diff --git a/tools/webpack/packages.js b/tools/webpack/packages.js index 3dc8407d7974b9..a62e9235b18fd8 100644 --- a/tools/webpack/packages.js +++ b/tools/webpack/packages.js @@ -167,4 +167,10 @@ module.exports = { endYear: 2040, } ), ].filter( Boolean ), + resolve: { + fallback: { + fs: false, + zlib: false, + }, + }, };