Skip to content

Commit d82e238

Browse files
author
Pavithra K
committed
Changes headers
1 parent e53bab7 commit d82e238

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

content/how-to/shim.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: How to Shim Third Party Libraries?
44

55
`webpack` as a module bundler can understand modules written as ES2015 modules, CommonJS or AMD. But many times, while using third party libraries, we see that they expect dependencies which are global aka `$` for `jquery`. They might also be creating global variables which need to be exported. Here we will see different ways to help webpack understand these __broken modules__.
66

7-
### Prefer unminified src(CommonJs/AMD) files over bundled `dist` versions.
7+
## Prefer unminified CommonJs/AMD files over bundled `dist` versions.
88

99
Most modules link the `dist` version in the `main` field of their `package.json`. While this is useful for most developers, for webpack it is better to alias the src version because this way webpack is able to optimize dependencies better (e.g. when using the [DedupePlugin](/concepts/plugins#DedupePlugin)). However in most cases `dist` works fine as well.
1010

@@ -21,7 +21,7 @@ module.exports = {
2121
};
2222
```
2323

24-
### ProvidePlugin
24+
## ProvidePlugin
2525
The [ProvidePlugin](/concepts/plugins#ProvidePlugin) makes a module available as a variable in every other module required by `webpack`. The module is required only if you use the variable.
2626
Most legacy modules rely on the presence of specific globals, like jQuery plugins do on `$` or `jQuery`. In this scenario, you can configure webpack to prepend `var $ = require(“jquery”)` everytime it encounters the global `$` identifier.
2727

@@ -38,7 +38,7 @@ var webpack = require("webpack");
3838
]
3939
```
4040

41-
### `imports-loader`
41+
## `imports-loader`
4242

4343
[`imports-loader`](https://github.com/webpack/imports-loader) inserts necessary globals into the required legacy module.
4444
For example, Some legacy modules rely on `this` being the `window` object. This becomes a problem when the module is executed in a CommonJS context where `this` equals `module.exports`. In this case you can override `this` using the `imports-loader`.
@@ -67,7 +67,7 @@ module: {
6767
}
6868
```
6969

70-
### `exports-loader`
70+
## `exports-loader`
7171

7272
Let's say a library creates a global variable that it expects it's consumers to use. In this case we can use [`exports-loader`](https://github.com/webpack/exports-loader), to export that global variable in CommonJS format.
7373

@@ -85,7 +85,7 @@ module: {
8585
}
8686
```
8787

88-
### `scripts-loader`
88+
## `scripts-loader`
8989

9090
The [scripts-loader](https://github.com/webpack/script-loader) evaluates code in the global context, just like you would add the code into a `script` tag. In this mode every normal library should work. require, module, etc. are undefined.
9191
Note: The file is added as string to the bundle. It is not minimized by `webpack`, so use a minimized version. There is also no dev tool support for libraries added by this loader.
@@ -98,7 +98,7 @@ require('script-loader!legacy.js')
9898
globalLegacyVariable() // This global variable will be added as a result of the script loader
9999
```
100100

101-
### `noParse` option
101+
## `noParse` option
102102

103103
When there is no AMD/CommonJS version of the module and you want to include the `dist`, you can flag this module as `noParse`. Then `webpack` will just include the module without parsing it, which can be used to improve the build time. This means that any feature requiring the AST, like the `ProvidePlugin`, will not work.
104104

0 commit comments

Comments
 (0)