Skip to content

JSON as config value not working #76

@WebReflection

Description

@WebReflection

Even with workers, it's apparently not possible to pass JSON directly, see:

Working

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script type="module" src="https://cdn.jsdelivr.net/npm/polyscript"></script>
    <script type="module">
        const script = Object.assign(document.createElement("script"), {
            type: "pyodide",
            textContent: `
                print("Hello World")
            `,
        });

        script.toggleAttribute("worker");
        script.setAttribute("config", "./config.json");

        document.body.appendChild(script);
    </script>
</head>
</html>

config.json

{
    "packages": [
        "protobuf"
    ]
}

NOT Working

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script type="module" src="https://cdn.jsdelivr.net/npm/polyscript"></script>
    <script type="module">
        const script = Object.assign(document.createElement("script"), {
            type: "pyodide",
            textContent: `
                print("Hello World")
            `,
        });

        script.toggleAttribute("worker");
        script.setAttribute("config", JSON.stringify({
            packages: ["protobuf"]
        }));

        document.body.appendChild(script);
    </script>
</head>
</html>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions