Initial naive approach to separating out node.js content #9557
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As a part of #9549, @pmario was concerned that including NPM specific code in boot.js was inappropriate. He's probably right, However, there is a bunch of other NPM and Node.js specific code already there. This is a naive and initial proposal for how that code could be removed and placed into a
boot/bootnode.jsfile so that it:This is a draft for discussion. Currently, this PR works, but all it's doing is yanking a block of node specific code out and putting it into another file, and then boot.js imports that file. This way is entirely backward incompatible.
However, if we're willing to be a little backward incompatible, this could be a much better solution.
$twas an argument, because it's still needed, but it probably shouldn't be.$tw.utils.each, which we don't have to use here. This is code that will ONLY run on Node.js, so we could safely use the array forEach method and such.$tw.utils.getFileExtensionInfo, but I'd probably just copy them and make simpler implementations.$tw.nodeinstead of$tw. As far as I can tell,$tw.nodeis just an empty object anyway, so it'd be perfect, and this would do much better sandboxing.Thoughts? This PR took me 10 minutes to make, so it's no big deal if we don't want to deal with this for 5.4.0. I'm mostly proposing this because it would provide a way to introduce the NPM stuff without clogging up the standalone wiki even more.