Skip to content

Commit

Permalink
Use static copy plugin to fetch the correct esm file and put it in a …
Browse files Browse the repository at this point in the history
…virtual 'assets' folder.
  • Loading branch information
Benjamin Clark committed Apr 12, 2024
1 parent 12e3468 commit 16ee263
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
3 changes: 2 additions & 1 deletion site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"eslint-plugin-react": "^7.34.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
"vite": "^5.2.8"
"vite": "^5.2.8",
"vite-plugin-static-copy": "^1.0.2"
},
"volta": {
"node": "20.11.1"
Expand Down
4 changes: 1 addition & 3 deletions site/src/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@ import ReactDOM from 'react-dom/client'
import App from './App.jsx'
import './index.css'
import initWasm, {ParquetFile} from "@geoarrow/geoarrow-wasm/esm/index.js";
import index_bg from '/index_bg.wasm?url'

ReactDOM.createRoot(document.getElementById('root')).render(
<React.StrictMode>
<App />
</React.StrictMode>,
)

console.log(`Attempting to load parquet-wasm from url '${index_bg}'`)
await initWasm(index_bg);
await initWasm();

const url =
"https://overturemaps-us-west-2.s3.amazonaws.com/release/2023-11-14-alpha.0/theme=transportation/type=segment/part-00158-6cb89013-4ec2-4b94-8e4b-8e27c7d30865.c000.zstd.parquet";
Expand Down
18 changes: 13 additions & 5 deletions site/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { viteStaticCopy } from 'vite-plugin-static-copy'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
plugins: [
react(),
viteStaticCopy({
targets: [
{
src: 'node_modules/@geoarrow/geoarrow-wasm/esm/index_bg.wasm',
dest: 'assets'
}
]
})
],
build: {
target: 'esnext',
},
optimizeDeps: {
exclude: ["@rollup/browser"],
},
}
})

0 comments on commit 16ee263

Please sign in to comment.