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

[Miniflare 2] Use scriptPath if available as the filePath of the script #736

Merged
merged 4 commits into from
Nov 8, 2023

Conversation

frandiox
Copy link
Contributor

@frandiox frandiox commented Nov 1, 2023

Hi! 👋

While adding support for HMR, we update our code, rebuild, and then call Miniflare's setOptions(...) to reload the code in Miniflare. However, Miniflare doesn't reload when using scriptPath because it caches its content.

Therefore, we switched to using script: await readFile(scriptPath) instead, and this forces Miniflare to update on every setOptions call.

The downside is that we broke sourcemaps 🙃 . The fix for sourcemaps looks like this (we look for <script> and then read the bundle sourcemap file). However, we still have step-debugging broken due to the same issue.

This change in Miniflare 2 fixes both, sourcemaps and step-debugging in VSCode when using script and scriptPath together because the latter will be used as the filePath of the script.

Alternatively, fixing the reloading of scriptPath is also possible -- but I already forgot where that part of the code was 😅

Copy link

changeset-bot bot commented Nov 1, 2023

⚠️ No Changeset found

Latest commit: 98f0212

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

@mrbbot mrbbot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Thanks for submitting this PR! Added a few minor comments, then I'll get this merged.

.changeset/empty-dogs-lie.md Outdated Show resolved Hide resolved
packages/core/src/plugins/core.ts Outdated Show resolved Hide resolved
@mrbbot mrbbot merged commit 90797a8 into cloudflare:master Nov 8, 2023
4 of 6 checks passed
@frandiox
Copy link
Contributor Author

Could we get this released? 🙏

@mrbbot
Copy link
Contributor

mrbbot commented Nov 13, 2023

Yep, want to get undici bumped first (#738), but then should be able to release.

@mrbbot
Copy link
Contributor

mrbbot commented Jan 17, 2024

Hey! 👋 Apologies for the delay, but this has now been released as part of miniflare@2.14.2. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants