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

Add python support for remote dev #5119

Merged
merged 4 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/kind-ducks-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": minor
---

Python support for remote dev
garrettgu10 marked this conversation as resolved.
Show resolved Hide resolved
11 changes: 9 additions & 2 deletions packages/wrangler/src/deployment-bundle/source-url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
import { pathToFileURL } from "url";
import type { CfModule } from "./worker";

function withSourceURL(source: string, sourcePath: string) {
function withSourceURL(source: string, sourcePath: string, isPython = false) {
if (isPython) {
return `${source}\n# sourceURL=${pathToFileURL(sourcePath)}`;

Check warning on line 7 in packages/wrangler/src/deployment-bundle/source-url.ts

View check run for this annotation

Codecov / codecov/patch

packages/wrangler/src/deployment-bundle/source-url.ts#L7

Added line #L7 was not covered by tests
garrettgu10 marked this conversation as resolved.
Show resolved Hide resolved
}
return `${source}\n//# sourceURL=${pathToFileURL(sourcePath)}`;
}

Expand All @@ -17,7 +20,11 @@
modules: CfModule[]
): { entrypointSource: string; modules: CfModule[] } {
let entrypointSource = fs.readFileSync(entrypointPath, "utf8");
entrypointSource = withSourceURL(entrypointSource, entrypointPath);
entrypointSource = withSourceURL(
entrypointSource,
entrypointPath,
entrypointPath.endsWith(".py")
);

modules = modules.map((module) => {
if (
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/dev/remote.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ async function createRemoteWorkerInit(props: {
main: {
name: path.basename(props.bundle.path),
filePath: props.bundle.path,
type: getBundleType(props.format),
type: getBundleType(props.format, path.basename(props.bundle.path)),
content,
},
modules,
Expand Down
Loading