Skip to content

Commit 4f1a5f1

Browse files
authored
Include reference to defer option when shimming (#3149)
* Include reference to defer option when shimming and link to webpack docs * Update troubleshooting.md
1 parent 32cd6b2 commit 4f1a5f1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

docs/troubleshooting.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,11 @@ default: &default
160160
161161
### Using global variables for dependencies
162162
163-
If you want to access any dependency without importing it everywhere or use it directly in your dev tools, please check: [https://webpack.js.org/plugins/provide-plugin/](https://webpack.js.org/plugins/provide-plugin/)
163+
If you want to access any dependency without importing it everywhere or use it directly in your dev tools, please check: [https://webpack.js.org/plugins/provide-plugin/](https://webpack.js.org/plugins/provide-plugin/) and the [webpack docs on shimming globals](https://webpack.js.org/guides/shimming/#shimming-globals).
164+
165+
Note, if you are exposing globals, like jQuery, to non-webpack dependencies (like an inline script) via the [expose-loader](https://webpack.js.org/loaders/expose-loader/), you will need to override the default of `defer: true` to be `defer:false` your call to the `javascript_pack_tag` so that the browser will load your bundle to setup the global variable before other code depends on it. However, you really should try to remove the dependendency on such globals.
166+
167+
Thus ProvidePlugin manages build-time dependencies to global symbols whereas the expose-loader manages runtime dependencies to global symbols.
164168

165169
**You don't need to assign dependencies on `window`.**
166170

0 commit comments

Comments
 (0)