Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not working examples for bare-browser and esbuild-browser #438

Closed
uros87 opened this issue Nov 30, 2021 · 10 comments
Closed

not working examples for bare-browser and esbuild-browser #438

uros87 opened this issue Nov 30, 2021 · 10 comments

Comments

@uros87
Copy link

uros87 commented Nov 30, 2021

when I try to run examples for those two projects ( bare-browser and esbuild-browser), I get errors. I cloned whole project and tried to run it.
Can someone give more info about it?

Also, can someone point me to working example for react and vanilla JS front-end project?

@Alex-Monahan
Copy link

Thanks for giving it a try! What errors are you getting? What environment are you working in?

@ankoh
Copy link
Member

ankoh commented Nov 30, 2021

The examples are built with our CI and should work.
But they currently expect that the wasm modules are compiled within the project which is a little bit involved.

E.g. the bare browser example copies the wasm modules here:

const DUCKDB_DIST = '../../packages/duckdb-wasm/dist/';
fs.copyFile(path.resolve(DUCKDB_DIST, 'duckdb-browser.mjs'), './duckdb-browser.mjs', printErr);
fs.copyFile(path.resolve(DUCKDB_DIST, 'duckdb.wasm'), './duckdb.wasm', printErr);
fs.copyFile(path.resolve(DUCKDB_DIST, 'duckdb-next.wasm'), './duckdb-next.wasm', printErr);
fs.copyFile(path.resolve(DUCKDB_DIST, 'duckdb-browser.worker.js'), './duckdb-browser.worker.js', printErr);
fs.copyFile(path.resolve(DUCKDB_DIST, 'duckdb-browser-next.worker.js'), './duckdb-browser-next.worker.js', printErr);
.
You'd have to point this to something like ./node_modules/@duckdb/duckdb-wasm/dist instead.

@ankoh
Copy link
Member

ankoh commented Nov 30, 2021

We could maybe make the examples independent of the monorepo at some point.
I agree that we should add a React example with a bundler like webpack.

@uros87
Copy link
Author

uros87 commented Nov 30, 2021

Hey Alex and ankoh thanks for answering.
I get:
GET http://127.0.0.1:8080/duckdb-browser.mjs net::ERR_ABORTED 404 (Not Found),
when i run examples.

@Alex-Monahan
I'm running in Ubuntu 18.04 if you mean env by that.

@ankoh
when i changed this line of code with this I still get the same error

Screenshot from 2021-11-30 20-42-14

and again thank you for your help!

@ankoh
Copy link
Member

ankoh commented Nov 30, 2021

You are still running the example in the monorepo. Copy the example folder out of the monorepo yarn workspace, fix the path and run npm install in the example folder.

The monorepo has it's yarn workspace node_modules at the root of the project which won't work as is.
I see that this can be confusing, the examples should just be independent of the monorepo.

@ankoh
Copy link
Member

ankoh commented Nov 30, 2021

Ah alternatively, you can do the following to run the examples in the monorepo:

  1. Clone the repo
  2. Run yarn install
  3. Run ./scripts/npm_restore.sh 1.11.1-dev54.0
  4. Run make examples

This will copy the published dist folder from npm.

@ankoh
Copy link
Member

ankoh commented Dec 1, 2021

Closing this for now since this works as intended. We could track react examples in a dedicated issue.

@ankoh ankoh closed this as completed Dec 1, 2021
@uros87
Copy link
Author

uros87 commented Dec 1, 2021

Thanks ankoh on thorough answers.
But I don't have a success to run example for bare-browser in isolation, though i successfully ran example in mono repo.

I've followed your instructions and i get

Screenshot from 2021-12-01 16-41-44

Screenshot from 2021-12-01 16-44-12

@ankoh
Copy link
Member

ankoh commented Dec 1, 2021

Did you install version 1.11.1-dev54.0 in the package.json?

@uros87
Copy link
Author

uros87 commented Dec 1, 2021

"@duckdb/duckdb-wasm": "1.11.1-dev54.0"

"@duckdb/duckdb-wasm": "^1.11.0"

I have tried with both of these versions, but I get the same error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants