Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

stephen
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;
},

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
@oleghein oleghein mentioned this pull request Jun 27, 2023
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

Successfully merging this pull request may close these issues.

1 participant