fix(frontend): migrate to new wasm loading method

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2022-12-28 19:13:49 +01:00
parent bf777704a6
commit 5a36b13091
2 changed files with 1 additions and 12 deletions

View file

@ -58,14 +58,11 @@ const rawNextConfig = {
] ]
}) })
const wasmModulePath = path.dirname(require.resolve('@hpcc-js/wasm'))
const emojiPickerDataModulePath = path.dirname(require.resolve('emoji-picker-element-data/en/emojibase/data.json')) const emojiPickerDataModulePath = path.dirname(require.resolve('emoji-picker-element-data/en/emojibase/data.json'))
config.plugins.push( config.plugins.push(
new CopyWebpackPlugin({ new CopyWebpackPlugin({
patterns: [ patterns: [
{ from: path.join(wasmModulePath, 'graphvizlib.wasm'), to: 'static/js' },
{ from: path.join(wasmModulePath, 'expatlib.wasm'), to: 'static/js' },
{ {
from: emojiPickerDataModulePath, from: emojiPickerDataModulePath,
to: 'static/js/emoji-data.json' to: 'static/js/emoji-data.json'

View file

@ -30,15 +30,7 @@ export const GraphvizFrame: React.FC<CodeProps> = ({ code }) => {
value: graphvizImport, value: graphvizImport,
error: libLoadingError, error: libLoadingError,
loading: isLibLoading loading: isLibLoading
} = useAsync( } = useAsync(() => import(/* webpackChunkName: "d3-graphviz" */ 'd3-graphviz'), [])
async () =>
import(/* webpackChunkName: "d3-graphviz" */ '@hpcc-js/wasm')
.then((wasmPlugin) => {
wasmPlugin.wasmFolder(`${basePath}/_next/static/js`)
})
.then(() => import(/* webpackChunkName: "d3-graphviz" */ 'd3-graphviz')),
[]
)
const showError = useCallback((error: string) => { const showError = useCallback((error: string) => {
if (!container.current) { if (!container.current) {