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

fix react refresh sourcemap in dev mode #1963

Closed
wants to merge 2 commits into from
Closed

fix react refresh sourcemap in dev mode #1963

wants to merge 2 commits into from

Conversation

magic-akari
Copy link

Changes

This PR will fix react refresh plugin source maps in dev mode.
related issue: #1213

Testing

  • plugins/plugin-react-refresh/test/plugin.test.js:
    add new reactRefreshOptions config option and remove mockBabel function.
  • test-dev:
    add react-source-map test files

Docs

bug fix only

@vercel
Copy link

vercel bot commented Dec 13, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/pikapkg/snowpack/evxmawgtg
✅ Preview: https://snowpack-git-fork-magic-akari-fix-sourcemap-dev-mo-1e0d13.pikapkg.vercel.app

@magic-akari

This comment has been minimized.

@magic-akari
Copy link
Author

sokra github io_source-map-visualization_

Copy link
Contributor

@Xiot Xiot left a comment

Choose a reason for hiding this comment

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

Nice. I was just about to finish up my own PR to fix the sourcemap support.

@@ -0,0 +1,8 @@
/** React Refresh: Connect **/
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: spelling... reatc in this file and the next should be react

if (destBuildFile.code !== result) {
destBuildFile.map = undefined;
if (config.buildOptions.sourceMaps && (destExt === '.js' || destExt === '.css')) {
logger.warn(`source-map file not found in [${debugPath}]`, {name: step.name});
Copy link
Contributor

Choose a reason for hiding this comment

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

Technically you could still have inline sourcemaps which wouldn't have an external map

outputMap = await composeSourceMaps(filePath, destBuildFile.map, outputMap);
}
} else if (destExt === '.js' || destExt === '.css') {
logger.warn(`source-map file not found in [${debugPath}]`, {name: step.name});
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment about inline sourcemaps

outputMap = typeof map === 'object' ? JSON.stringify(map) : map;
if (destBuildFile.map) {
outputMap = await composeSourceMaps(filePath, destBuildFile.map, outputMap);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do the sourcemaps need to be composed?
I would assume that that since the plugin has access to the sourcemap, it would potentially compose the maps.

@davidwallacejackson
Copy link

Hey, just checking -- is this PR still alive? Really excited to try out Snowpack and TS sourcemap support is a blocker for me. Happy to pitch in if there's something I can do to get this over the finish line.

@melissamcewen melissamcewen added this to Needs Triage in Triage Mar 11, 2021
@melissamcewen melissamcewen moved this from Needs Triage to Triaging in Triage Mar 12, 2021
@magic-akari
Copy link
Author

@davidwallacejackson Sorry to reply so late. I'm still following this issue. There seems to be a lot of conflicts here. I will double check the conflicts a little later.

@melissamcewen melissamcewen moved this from Triaging to Ready to Implement in Triage Mar 15, 2021
@melissamcewen melissamcewen moved this from Ready to Implement to Ready for review in Triage Mar 15, 2021
@FredKSchott
Copy link
Owner

Sorry @magic-akari, #2707 changed a lot of Snowpack internals. I'd actually love to help rebase this PR for you, if you don't mind waiting a little bit for me to make time.

@FredKSchott
Copy link
Owner

Okay, codebase has been refactored and is stable enough that rebasing this won't be a waste of time :) Appreciate everyones patience here.

@magic-akari if I rebase this for you onto main, are you still interested in getting it merged?

@FredKSchott FredKSchott moved this from Ready for review to Evaluating PR in Triage Mar 31, 2021
@magic-akari
Copy link
Author

Yes. Please rebase it.

@FredKSchott
Copy link
Owner

Alright, I attempted a rebase here: https://github.com/snowpackjs/snowpack/tree/fix-sourcemap-dev-mode-react-refresh

Unfortunately, quite a bit has changed. Normally git would be okay here, but the refactor included reorganizing files and moving logic around. This has made rebasing difficult.

What I might suggest instead is attempting to re-create this PR on top of main. As you go, it should become obvious where code has changed and hopefully obvious where it has moved to if it has moved. I think going line by line like this will be better than attempting to debug any unknown issues in a bad rebase.

Sorry again for the delay here.No pressure if you don't have the time to recreate: we appreciate the contribution regardless. I'm going to close this PR for now, but feel free to create a new PR or just ping me in this branch if you're able to get this updated and I can take another look.

Triage automation moved this from Evaluating PR to Closed Mar 31, 2021
@magic-akari magic-akari deleted the fix-sourcemap-dev-mode-react-refresh branch February 9, 2022 14:34
@FredKSchott FredKSchott removed this from Closed in Triage Apr 20, 2022
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.

None yet

4 participants