Skip to content

Instantly share code, notes, and snippets.

@andrewvmail
Last active July 8, 2022 20:39
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
hot-fix-for-parcel-react-pdf-import-bug
#!/bin/bash
# https://github.com/diegomura/react-pdf/pull/1891
set -eu
echo "[ post install script ] running hot-fix at post install"
patch -p0 --forward \
node_modules/@react-pdf/renderer/lib/react-pdf.browser.es.js \
scripts/renderer.patch || true
patch -p0 --forward \
node_modules/@react-pdf/primitives/src/index.js \
scripts/primitives.patch || true
{
...,
"scripts": {
"postinstall": "./scripts/hot-fix.sh",
},
...
}
--- node_modules/@react-pdf/primitives/src/index.js 2022-06-04 16:38:56.091000000 -0700
+++ "node_modules/@react-pdf/primitives/src/index copy.js" 2022-07-06 21:40:30.546641600 -0700
@@ -22,3 +22,30 @@
export const TextInstance = 'TEXT_INSTANCE';
export const LinearGradient = 'LINEAR_GRADIENT';
export const RadialGradient = 'RADIAL_GRADIENT';
+
+export default {
+ G,
+ Svg,
+ View,
+ Text,
+ Link,
+ Page,
+ Note,
+ Path,
+ Rect,
+ Line,
+ Stop,
+ Defs,
+ Image,
+ Tspan,
+ Canvas,
+ Circle,
+ Ellipse,
+ Polygon,
+ Document,
+ Polyline,
+ ClipPath,
+ TextInstance,
+ LinearGradient,
+ RadialGradient,
+}
\ No newline at end of file
--- node_modules/@react-pdf/renderer/lib/react-pdf.browser.es.js 2022-07-05 00:02:28.704999000 -0700
+++ "node_modules/@react-pdf/renderer/lib/react-pdf.browser.es copy.js" 2022-07-06 21:40:50.936641600 -0700
@@ -1,5 +1,5 @@
import _extends from '@babel/runtime/helpers/extends';
-import * as primitives from '@react-pdf/primitives';
+import primitives from '@react-pdf/primitives';
export * from '@react-pdf/primitives';
import queue from 'queue';
import React, { useRef, useState, useEffect } from 'react';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment