Skip to content

Comments

Remove NetsTool and nets dependency#113

Merged
adroitwhiz merged 1 commit intoscratchfoundation:developfrom
adroitwhiz:node-fetch
Jun 2, 2020
Merged

Remove NetsTool and nets dependency#113
adroitwhiz merged 1 commit intoscratchfoundation:developfrom
adroitwhiz:node-fetch

Conversation

@adroitwhiz
Copy link
Contributor

@adroitwhiz adroitwhiz commented Nov 11, 2019

Proposed Changes

This PR removes NetsTool and the dependency on the nets package.

Reason for Changes

Regardless of whether it's running in Node or the browser, nets pulls in both the request library (which is in maintenance mode) and the xhr library. Both have many dependencies that add around ~100kb to the bundle size:
image

These include, but are not limited to, 13 different packages depended upon by a polyfill for String.prototype.trim, a function which is supported in all browsers released in the last 7 years.

According to MDN, the Fetch API is supported on all browsers that Scratch targets, making the nets fallback unnecessary:
image

image

To retain Node support (e.g. for running tests), I have added node-fetch, an implementation of the Fetch API for Node, as a dev-only dependency.

I also have a branch which removes the nets dependency from scratch-vm, but I don't want to submit that until you approve of this one to avoid submitting too many potentially unwanted PRs.

Test Coverage

Testing will have to be manually done across browsers.

@adroitwhiz adroitwhiz force-pushed the node-fetch branch 2 times, most recently from 8aa5ad3 to cdc6ad1 Compare November 11, 2019 23:13
Copy link
Contributor

@cwillisf cwillisf left a comment

Choose a reason for hiding this comment

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

👍

@fsih
Copy link
Contributor

fsih commented Jun 2, 2020

Testing: load and save projects in many browsers

@adroitwhiz adroitwhiz merged commit a4a5f10 into scratchfoundation:develop Jun 2, 2020
@rschamp
Copy link
Contributor

rschamp commented Apr 27, 2021

🎉 This PR is included in version 1.3.4 🎉

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants