Skip to content

Commit 02b5982

Browse files
authored
Merge pull request #89 from ut-code/no-pyodide-import
pyodideをpackage.jsonから削除
2 parents a561e4f + 0d7920d commit 02b5982

File tree

7 files changed

+5
-31
lines changed

7 files changed

+5
-31
lines changed

app/[docs_id]/page.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { getCloudflareContext } from "@opennextjs/cloudflare";
33
import { readFile } from "node:fs/promises";
44
import { join } from "node:path";
55
import { MarkdownSection, splitMarkdown } from "./splitMarkdown";
6-
import pyodideLock from "pyodide/pyodide-lock.json";
76
import { PageContent } from "./pageContent";
87
import { ChatHistoryProvider } from "./chatHistory";
98
import { getChatFromCache } from "@/lib/chatHistory";
@@ -39,12 +38,6 @@ export default async function Page({
3938
notFound();
4039
});
4140
}
42-
mdContent = mdContent.then((text) =>
43-
text.replaceAll(
44-
"{process.env.PYODIDE_PYTHON_VERSION}",
45-
String(pyodideLock.info.python)
46-
)
47-
);
4841

4942
const splitMdContent: Promise<MarkdownSection[]> = mdContent.then((text) =>
5043
splitMarkdown(text)

app/terminal/python/runtime.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export function usePyodide(): RuntimeContext {
2727
type MessageToWorker =
2828
| {
2929
type: "init";
30-
payload: { PYODIDE_CDN: string; interruptBuffer: Uint8Array };
30+
payload: { interruptBuffer: Uint8Array };
3131
}
3232
| {
3333
type: "runPython";
@@ -90,11 +90,9 @@ export function PyodideProvider({ children }: { children: ReactNode }) {
9090
}
9191
};
9292

93-
// next.config.ts 内でpyodideをimportし、バージョンを取得している
94-
const PYODIDE_CDN = `https://cdn.jsdelivr.net/pyodide/v${process.env.PYODIDE_VERSION}/full/`;
9593
postMessage<InitPayloadFromWorker>({
9694
type: "init",
97-
payload: { PYODIDE_CDN, interruptBuffer: interruptBuffer.current },
95+
payload: { interruptBuffer: interruptBuffer.current },
9896
}).then(({ success }) => {
9997
if (success) {
10098
setReady(true);

next.config.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { NextConfig } from "next";
22
import { initOpenNextCloudflareForDev } from "@opennextjs/cloudflare";
3-
import { version as pyodideVersion } from "pyodide";
43

54
initOpenNextCloudflareForDev();
65

@@ -12,9 +11,6 @@ const nextConfig: NextConfig = {
1211
typescript: {
1312
ignoreBuildErrors: true,
1413
},
15-
env: {
16-
PYODIDE_VERSION: pyodideVersion,
17-
},
1814
serverExternalPackages: ["@prisma/client", ".prisma/client"],
1915
async headers() {
2016
// pyodideをworkerで動作させるために必要

package-lock.json

Lines changed: 0 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
"next": "<15.5",
3131
"pg": "^8.16.3",
3232
"prismjs": "^1.30.0",
33-
"pyodide": "^0.28.1",
3433
"react": "19.1.0",
3534
"react-ace": "^14.0.1",
3635
"react-dom": "19.1.0",

public/docs/python-1.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ macOSでは、**Homebrew** というパッケージマネージャを使って
3333

3434
### ブラウザで今すぐ試す
3535

36-
このウェブサイトではドキュメント内に Python {process.env.PYODIDE_PYTHON_VERSION} の実行環境を埋め込んでいます
36+
このウェブサイトではドキュメント内にPython3の実行環境を埋め込んでいます
3737
以下のように青枠で囲われたコード例には自由にPythonコードを書いて試すことができます。気軽に利用してください。
3838

3939
```python-repl:1

public/pyodide.worker.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Pyodide web worker
22
let pyodide;
33
let pyodideOutput = [];
4+
const PYODIDE_CDN = `https://cdn.jsdelivr.net/pyodide/v0.28.1/full/`;
45

56
// Helper function to read all files from the Pyodide file system
67
function readAllFiles() {
@@ -19,7 +20,7 @@ function readAllFiles() {
1920
}
2021

2122
async function init(id, payload) {
22-
const { PYODIDE_CDN, interruptBuffer } = payload;
23+
const { interruptBuffer } = payload;
2324
if (!pyodide) {
2425
importScripts(`${PYODIDE_CDN}pyodide.js`);
2526
pyodide = await loadPyodide({

0 commit comments

Comments
 (0)