Local http server for testing in uncompiled mode #5008
Merged
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.
The basics
The details
The problem
Unlike
goog.providepackages,goog.modulemodules are loaded usingXMLHttpRequestwhen in uncompiled mode. Because browsers treatfile:URLs as each being a separate, unique origin, CORS rules prevent browsers from loadinggoog.modulemodules fromfile:URLs.Proposed Changes
Use the http-server npm to serve the repository root directory on localhost:8080.
Provide a script so that you can type
npm startto start the local http server and automatically open a browser window pointing attests/playground.html.Modify the
setBackgroundColourfunction in the playgrounds to provide the usual lilac background onlocahostURLs and a sickly green one if using afile:URL (all of which will soon stop working).(The background doesn't actually appear to be visible in the advanced playground.)
Developer Behaviour Before Change
We have opened
file:///.../blockly/tests/playground.htmlto do local manual testing.Developer Behaviour After Change
We will run
npm startto do local manual testing. To access the advanced playground, we need only then navigate to http://localhost:8080/tests/playgrounds/advanced_playground.html.Test Coverage
Tested manually locally on macOS.
Documentation
At minimum:
should be updated with instructions to run
npm start(afternpm install) to load up the playground.(I don't believe I have the ability to modify either of these directly.)
Additional Information
Should this PR target the
goog_modulebranch instead ofdevelop? There's nothinggoog.modulespecific about it (i.e., we wouldn't necessarily want to undo this even if the whole module migration is abandoned), but it is only necessary because of that migration.(N.B.: I'm planning to fast-forward
goog_moduleto the tip ofdeveloponce #4968 is merged, before it gets any PRs of its own.)