How do I load javascript libraries within html-wasm?
At a glance
The community member is interested in using html-wasm to deploy marimo and is having trouble accessing data in S3. Since boto3 is not available in Pyodide, they tried using the TS client for AWS S3, but are having trouble loading the client library. The community members discuss alternative approaches, such as using polars or duckdb, but encounter issues with boto3 dependencies. Eventually, the community member finds success using the requests-aws4auth library to access the S3 data. The issue is resolved.
I am very interested in using html-wasm to deploy marimo, and I am currently working through the issue of accessing data in S3. Since boto3 is not available in Pyodide, I was just going to use the TS client for AWS S3. The setup is working fine for running the JS code from within Pyodide (import js, js.eval, etc.). However, since I'm not very experienced with TS, I'm having trouble loading the client library appropriately.
I have:
# Load the AWS SDK for JavaScript js.self.AWS = await js.eval(""" (async () => {{ import {{ S3Client, GetObjectCommand }} from "@aws-sdk/client-s3";
// Replace with your actual credentials const client = new S3Client({{ region: "{region}", credentials: {{ accessKeyId: "{access_key_id}", secretAccessKey: "{secret_access_key}", sessionToken: "{session_token}", }} }});
return {{ client }}; }})(); """.format( ....
But I get the error: This cell raised an exception: JsException('SyntaxError: Cannot use import statement outside a module')
requests ended up not working, mostly because it was too hard for me to figure out how to sign the request appropriately. However, I did end up working when I used this - https://pypi.org/project/requests-aws4auth/