-
Notifications
You must be signed in to change notification settings - Fork 70
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
Refactor npm package and add Worker support #203
Merged
Merged
Conversation
This file contains 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
minestarks
reviewed
Apr 24, 2023
minestarks
reviewed
Apr 25, 2023
minestarks
reviewed
Apr 25, 2023
Closed
swernli
approved these changes
Apr 26, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Signing off for the one change under compiler (addition of todo). Additionally, this PR could be a good place to move the compiler/qsc_wasm
folder to a top-level wasm
folder.
minestarks
reviewed
Apr 26, 2023
minestarks
reviewed
Apr 26, 2023
minestarks
reviewed
Apr 26, 2023
minestarks
reviewed
Apr 26, 2023
minestarks
reviewed
Apr 26, 2023
minestarks
reviewed
Apr 26, 2023
minestarks
approved these changes
Apr 26, 2023
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.
This PR cleans up the npm package so nearly all code is shared between node.js and the browser, with just a few lines in platform specific entry points. The platform specific entry points are now handled with 'conditional exports' in the package.json, so either Node.js or browser source consuming the package should just "import { ... } from 'qsharp'".
This PR also adds support for Worker threads, and moves the playground to use WebWorkers by default (getting all the wasm work such as compiling and simulating off the main UX thread). As this works similarly in both browser and Node.js, you can see in some of the unit tests added under ./npm/tests how this is used. (It's mostly the same as non-worker usage, just with one-line difference in initialization and clean-up.
As part of getting the above working, I also added configurable logging support. See ./npm/src/log.ts for details on that. (It should be pretty easy to wire this up to both VS Code "output channels" and macros from the Rust 'log' crate also).
I also made a lot of the TypeScript code more 'strongly typed', and it deals with a lot of string parsing and message handling in the 'npm' package now, avoid the need for consumers to do so.
Running the katas works, but I need to clean up the integration in the playground still for some of the refactoring before they are showing in the playground again (just commented out for now). I'll do that as part of a bigger playground UX clean-up.
I touched nearly every line of code in the npm package, so probably just easier to look at the code overall there, rather than the diff. Sorry :-/