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

Improve light client support #18

Merged
merged 12 commits into from
May 6, 2024
Merged

Improve light client support #18

merged 12 commits into from
May 6, 2024

Conversation

mfornos
Copy link
Collaborator

@mfornos mfornos commented May 2, 2024

  • Generate Esbuild browser bundle
  • Worker-threads compatibility via developit/web-worker lib
  • Test out in vite builds
  • Test out complete package in browser and node platforms (ensure nothing broken, test in external project and in examples/)
  • Adjust log level in the browser
  • Simplify usage with Vite (i.e. import worker directly from SDK and add browser export hint for worker entrypoint... :P)

@mfornos mfornos added the feature New feature or request label May 2, 2024
@mfornos
Copy link
Collaborator Author

mfornos commented May 3, 2024

Example Web App usage with Vite.

// ...
import SmolWorker from "@sodazone/ocelloids-sdk/worker?worker"

function createApis() {
  const provider = new ScProvider(
    Smoldot, polkadot
  );

  provider.connect({
    embeddedNodeConfig: {
      workerFactory: () => {
        return new SmolWorker({
          name: 'oc-smoldot'
        });
      }
    }
  });

  return new SubstrateApis({
    lc: { provider }
  });
}

vite.config.js:

import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react()]
})

It bundles properly a production build.

@mfornos mfornos changed the title Browser support Improve light client support May 3, 2024
@mfornos mfornos merged commit bbf65c2 into main May 6, 2024
1 check passed
@mfornos mfornos deleted the feature-browser-support branch May 6, 2024 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant