Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add support for es module and browser-only environment #539

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

Open
stephen wants to merge 4 commits into sql-js:master
base: master
Choose a base branch
Loading
from stephen:stephen/esmodule

Conversation

Copy link

@stephen stephen commented Jan 2, 2023

This PR addresses #284.

I've tested this change using the current create-react-app along with this webpack config:

configure: (webpackConfig) => {
 webpackConfig.resolve.extensions.push(".wasm");
 webpackConfig.experiments = {
 asyncWebAssembly: true,
 topLevelAwait: true,
 };
 webpackConfig.module.rules.forEach((rule) => {
 (rule.oneOf || []).forEach((oneOf) => {
 if (oneOf.type === "asset/resource") {
 oneOf.exclude.push(/\.wasm$/);
 }
 });
 });
 return webpackConfig;
},

Alaanor and besendorf reacted with thumbs up emoji
This was tricky to figure out. Using the ENVIRONMENT=web flag for the browser
build started causing prepared statements to fail - it would behave as if
no params were passed to db.exec("...", []) as the second arg.
It turns out that the closure compiler was removing the bind() call..
It's not clear to me why, but adding externs that map out the exported
structure fixes the issue.
Some other notes:
- emscripten runs with ADVANCED mode for closure compiler
- closure compiler reuses variables...
- use --closure-args=--debug and --closure-args=--pretty-print for clues
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /