Open tobiasBora opened 4 years ago
Moving to ES modules has made this even harder. It seems that browsers won't import ES modules from anywhere other than the the host of the web page doing the import.
I think Rollup https://rollupjs.org/ might make it fairly easy to generate a simple javascript file that could be referenced from within a browser. It goes against my current objective of reducing 3rd party dependencies, but it looks pretty simple to use.
Perhaps we could start hosting rollup'd files on jsqubits github pages 🤔
Rollup worked great in my case, thanks for pointing me to that. With that it even works locally and older browers, no issues with CORS anymore. And it's super simple to use: first install rollup (if you are using nix, it's just nix-shell -p nodePackages.rollup
) and run:
$ rollup lib/index.js --file bundleJsqubit.js --format iife --name bundleJsqubit
Then to use it in a project:
<script src="./bundleJsqubit.js"></script>
<script type="text/javascript">
jsqubits = bundleJsqubit.jsqubits; //
var bell_pair = jsqubits('|00>').hadamard(0).controlledX(0,1);
</script>
Hello,
First, thanks a lot for this great simulator, it will be quite practical for me. I just have a minor issue: would it be possible to provide from time to time a packed .js file for simple in-browser use? Because otherwise one need to install nodejs to write the code, or download the .js file used in the demo that may be outdated.
By the way, the README says:
However, neither
jsqubits.js
norjsqubitsmath.js
exist in this folder.