Skip to content

Commit

Permalink
fix: bundle latest dfa to fontkit (#1609)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeetiss committed Dec 18, 2021
1 parent 4c5d527 commit 3217a89
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 331 deletions.
5 changes: 5 additions & 0 deletions .changeset/beige-wombats-jump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@react-pdf/fontkit': minor
---

added `dfa@1.2.0` to browser bundle to remove `core-js@2` and `regenerator-runtime`
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@changesets/cli": "^2.17.0",
"@rollup/plugin-alias": "^3.1.8",
"@rollup/plugin-babel": "^5.3.0",
"@rollup/plugin-commonjs": "^18.0.0",
"@rollup/plugin-commonjs": "^21.0.1",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.0.6",
"@rollup/plugin-replace": "^3.0.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/fontkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@
"author": "Devon Govett <devongovett@gmail.com>",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.6.2",
"@react-pdf/unicode-properties": "^2.4.2",
"brotli": "^1.2.0",
"clone": "^1.0.4",
"deep-equal": "^1.0.0",
"dfa": "1.1.0",
"dfa": "^1.2.0",
"restructure": "^0.5.3",
"tiny-inflate": "^1.0.2",
"unicode-trie": "^0.3.0"
Expand Down
25 changes: 21 additions & 4 deletions packages/fontkit/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import replace from '@rollup/plugin-replace';
import ignore from 'rollup-plugin-ignore';
import { terser } from 'rollup-plugin-terser';
import localResolve from 'rollup-plugin-local-resolve';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import pkg from './package.json';

const cjs = {
Expand Down Expand Up @@ -80,16 +82,31 @@ const browserConfig = Object.assign({}, configBase, {
getESM({ file: 'lib/fontkit.browser.es.js' }),
getCJS({ file: 'lib/fontkit.browser.cjs.js' }),
],
plugins: configBase.plugins.concat(
babel(babelConfig({ browser: true })),
external: configBase.external
.filter(dep => dep !== 'dfa')
.concat(
'@babel/runtime/regenerator',
'@babel/runtime/helpers/createClass',
'@babel/runtime/helpers/applyDecoratedDescriptor',
'@babel/runtime/helpers/defineProperty',
'@babel/runtime/helpers/inheritsLoose',
),
plugins: [
ignore(['fs', 'brotli', 'brotli/decompress', './WOFF2Font']),
replace({
preventAssignment: true,
values: {
BROWSER: JSON.stringify(true),
},
}),
ignore(['fs', 'brotli', 'brotli/decompress', './WOFF2Font']),
),

json(),

resolve({ browser: true }),
commonjs({ include: /node_modules/ }),

babel(babelConfig({ browser: true })),
],
});

const browserProdConfig = Object.assign({}, browserConfig, {
Expand Down
Loading

0 comments on commit 3217a89

Please sign in to comment.