unplugin-pyscript-script
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

unplugin-pyscript-script

unplugin-pyscript-script is the plugin for PyScript script importing. When you are using PyScript with Vite, Webpack, Rollup..., it would be useful.

About PyScript, see PyScript.

Usage

About how to use the plugin for Vite, Webpack, Rollup..., see UnPlugin

Write your PyScript code to file with .script.py suffix

print("Let's compute π:")
def compute_pi(n):
    pi = 2
    for i in range(1,n):
        pi *= 4 * i ** 2 / (4 * i ** 2 - 1)
    return pi

pi = compute_pi(100000)
s = f"π is approximately {pi:.3f}"
print(s)
  • <py-script output="output-id"></py-script>
# output= "output-id"

import matplotlib.pyplot as plt
import numpy as np

x = np.random.randn(1000)
y = np.random.randn(1000)

fig, ax = plt.subplots()
ax.scatter(x, y)
fig

Import your .script.py file to js

import { script } from "./xxx.script.py"

Package Sidebar

Install

npm i unplugin-pyscript-script

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

3.93 kB

Total Files

5

Last publish

Collaborators

  • herberthe