Open
Conversation
As recommended by `@babel/plugin-transform-runtime`'s documentation: > (...) and @babel/runtime as a production dependency (since it's for > the "runtime"). Otherwise other packages trying to use `lib/brython-runner.js` will fail to find the files necessary for the code generated by the pacakge `@babel/plugin-transform-runtime`.
Since this file is loaded as a raw string by
`lib/core/brython-runner.js`, calls like
`require("@babel/runtime/...")` will not be resolved by webpack and will
be kept in the resulting string. Because of that, the loaded string will
fail to run in a Web worker. In order to solve this, let us turn
`lib/core/brython-runner.worker.js` into a bundle, so that those
`require()` calls are already resolved during build time.
guludo
added a commit
to guludo/revealjs-ace-brython
that referenced
this pull request
Mar 8, 2021
Fixes to allow importing the library. Those where already sent to upstream as pull request: pythonpad/brython-runner#2
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.
Hi there!
I was trying to use this library in another project and ran into some problems:
@babel/runtimewas missing frombrython-runnerdependency list. So, when I usedimport BrythonRunner from 'brython-runner/lib/brython-runner.js', webpack complained that could not find the modules required by the code generated by the@babel/plugin-transform-runtimeplugin.lib/core/brython-runner.jsloadslib/core/brython-runner.worker.jsas a raw string, so calls likerequire("@babel/runtime/...")generated by@babel/plugin-transform-runtimeare not resolved by webpack. That results in the code failing to execute in the Web worker.In this pull request I address problem (1) by adding
@babel/runtimeas a dependency, as recommended by the documentation. This is done in the first commit.As for problem (2), instead of generating
lib/core/brython-runner.worker.jsin thecompile-js-babelGulp task, I change the build configuration so thatlib/core/brython-runner.worker.jsis generated as a bundle by webpack. This is done in the second commit.Finally, the third commit regenerates files in
lib/, which was done viayarn run build.I hope the changes proposed here do not break other workflows already in use! :-) If they do, what would be the way of using this library in another project using webpack?
Best regards,
Gustavo Sousa