Commit 8372c16
committed
Fix Webpack warning caused by dynamic require
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.1 parent 0d0404b commit 8372c16
1 file changed
+8
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
63 | 65 | | |
64 | 66 | | |
65 | 67 | | |
| |||
102 | 104 | | |
103 | 105 | | |
104 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
105 | 110 | | |
106 | | - | |
107 | | - | |
| 111 | + | |
| 112 | + | |
108 | 113 | | |
109 | 114 | | |
110 | 115 | | |
| |||
0 commit comments