Fix Webpack error due to dynamic require#1
Draft
mjhanninen wants to merge 2 commits intomasterfrom
Draft
Conversation
05d9e8e to
7fe10bd
Compare
Webpack supports dynamic importing only for some special cases in which it is able to narrow down the set of packages to bundled. In the general case it just produces an empty (Webpack) context plus the warning stating that "the request of a dependency is an expression." Apparently the commit 120a1d7 changed the Javascript generated by wasm-bindgen so that the binding for the `require` became: ``` module.require(getStringFromWasm0(arg0, arg1)) ``` when it used to be: ``` getObject(arg0).require(getStringFromWasm0(arg1, arg2)) ``` In the latter case Webpack did not even realize that this code imported a package and, hence, did not try to bundle it. The new code triggers the bundling and because the dependency is fully dynamic Webpack has problems with it. This commit reverts partially the commit 120a1d7 so that the generated binding obfuscates the `require` call enough to hide it from Webpack again.
7fe10bd to
8372c16
Compare
Signed-off-by: Joe Richey <joerichey@google.com>
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.
This PR reverts the changes in commit 120a1d7 partially . In particular, it changes the wasm-bindgen binding of
module.requirementback to the older form. As a result the generated Javascript binding code looks now like:As a consequence Webpack does not detect this as a package import and, thus, does not attempt to bundle it which solves problem. It is safe skip the bundling of the
cryptopackage because (1) it is imported only on Node and (2) it comes with Node.Relevant issues: