allow tutorials and examples to remove dependencies from blocksprj#11397
Open
riknoll wants to merge 3 commits into
Open
allow tutorials and examples to remove dependencies from blocksprj#11397riknoll wants to merge 3 commits into
riknoll wants to merge 3 commits into
Conversation
srietkerk
requested changes
Jun 11, 2026
| const host = shareId ? new Host() : new SnippetHost("decl-build", { "main.ts" : "" }, { "blocksprj": "*" }); | ||
| const blocksprjConfig = readBlocksprjConfig(); | ||
|
|
||
| const host = shareId ? new Host() : new SnippetHost("decl-build", { "main.ts" : "" }, { ...blocksprjConfig.dependencies }); |
Contributor
There was a problem hiding this comment.
I think we need some checking around this because if readBlocksprjConfig returns undefined, trying to expand blocksprjConfig will throw an error.
Member
There was a problem hiding this comment.
throwing in cli on an invalid project build seems fine, though maybe an explicit exception would narrow in a bit quicker
| .map(l => l.replace(/\s*$/, '')) | ||
| .filter(line => !!line) | ||
| .forEach(line => { | ||
| .reduce((acc, lines) => { |
Contributor
There was a problem hiding this comment.
Just curious why this was changed?
jwunderl
approved these changes
Jun 11, 2026
| const host = shareId ? new Host() : new SnippetHost("decl-build", { "main.ts" : "" }, { "blocksprj": "*" }); | ||
| const blocksprjConfig = readBlocksprjConfig(); | ||
|
|
||
| const host = shareId ? new Host() : new SnippetHost("decl-build", { "main.ts" : "" }, { ...blocksprjConfig.dependencies }); |
Member
There was a problem hiding this comment.
throwing in cli on an invalid project build seems fine, though maybe an explicit exception would narrow in a bit quicker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
fixes microsoft/pxt-microbit#4058
for tutorials and markdown examples, dependencies specified using the
packagesnippet are merged into the dependencies of the default project. that's usually the behavior you want unless the package you're adding happens to conflict with a dependency of the default project.really, this only comes up in pxt-microbit where the bluetooth extension is not compatible with the default radio extension. up until now, there hasn't been any way to write a tutorial for bluetooth.
this PR fixes that issue by allowing you to remove packages from the default config like so:
as part of this change, i also had to fix a bunch of places in the CLI where we were lazy and added
blocksprjas a dependency to the config we use when compiling blocks snippets instead of doing the right thing and cloning its pxt.json.i think i got all of the places where the
packagesnippets are parsed in the codebase, but it's possible i could have missed one. it would be a good idea to test some docs pages just in case