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 [email protected] for browser builds #421

Merged
merged 2 commits into from
Oct 13, 2023
Merged

Fix [email protected] for browser builds #421

merged 2 commits into from
Oct 13, 2023

Conversation

cwillisf
Copy link
Contributor

@cwillisf cwillisf commented Oct 5, 2023

Resolves

  • Likely resolves ENG-107

Proposed Changes

Update the browser field in package.json to point to dist/web/scratch-storage.js instead of src/index.js

Reason for Changes

Browsers don't understand webpack loaders, so strictly speaking, this field has been incorrect since we first implemented default assets. We didn't notice because, within Scratch repositories, we always build with webpack. Removing the inline loader syntax in #412 made it so that dependents need to specify loader rules, and thus broke scratch-gui and others. Telling dependents to use the build output makes it so the loader is applied as part of the scratch-storage build process and doesn't need to be configured in every dependent. Also, FLUFFY FISHSTICKS this took SO much longer than it should have. It's exceptionally difficult to fix this at the scratch-gui level, which is what I was beating my head against for a few days. I'm very happysad that it's effectively a one-liner in scratch-storage.

Test Coverage

I enhanced the load-default-assets test to verify the exact size of each default asset. That way, we can be sure that the file contents are accurate instead of, for example, a filename or a data URI string. Basically, it now tests that the loader is doing its job and configured correctly. To do this, it needs to use the build output instead of the raw source.

This checks for things like accidentally using the filename as the file
content, etc.
Copy link

@AlexisGoodfellow AlexisGoodfellow left a comment

Choose a reason for hiding this comment

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

YOLO!

But for real, this looks good. Reasoning is very sound. Thanks for the context!

@cwillisf
Copy link
Contributor Author

The "good" news is: if this doesn't fix the problem, scratch-gui will still be broken and we're no worse off than yesterday. Hooray!(?)

@cwillisf cwillisf merged commit 135b4dc into develop Oct 13, 2023
4 checks passed
@cwillisf cwillisf deleted the fixes-for-gui branch October 13, 2023 16:37
@scratch-deployer
Copy link

🎉 This PR is included in version 2.3.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

3 participants