Skip to content

Commit b8cc7d9

Browse files
Christian Comptondpopp07
Christian Compton
authored andcommitted
chore: update documentation for webpack
1 parent ec87dc6 commit b8cc7d9

File tree

2 files changed

+32
-31
lines changed

2 files changed

+32
-31
lines changed

examples/webpack/README.md

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,39 @@ The following services do not support CORS
3232
* Visual Recognition (partial support)
3333
* Retrieve and Rank
3434

35+
Ideally, only the specific services used shoud be included, for example:
36+
37+
```js
38+
var ToneAnalyzerV3 = require('ibm-watson/tone-analyzer/v3');
39+
var AssistantV1 = require('ibm-watson/assistant/v1');
40+
```
41+
42+
**Not Recommended**: It's possible to load the entire library, but it is not recommended due to the added file size:
43+
44+
```js
45+
var watson = require('ibm-watson');
46+
```
47+
or
48+
```
49+
const { AssistantV1, ToneAnalyzerV3 } = require('ibm-watson');
50+
```
51+
52+
Additionally, when importing the entire library, the `shebang-loader` package is need and must be configured
53+
in webpack.config.js:
54+
55+
```js
56+
module: {
57+
rules: [{
58+
test: /JSONStream/,
59+
use: 'shebang-loader'
60+
}]
61+
}
62+
```
3563

3664
## Webpack configuration
3765

66+
The `ibm-watson` Node SDK version 5+ should work out of the box with most bundlers, including webpack. For versions below 5.0.0, the following configurations may be required to leverage the SDK in client environments.
67+
3868
In most cases, you will want the following in your configuration:
3969

4070

@@ -50,33 +80,4 @@ In most cases, you will want the following in your configuration:
5080

5181
Several services use the `fs` library, which won't work in browser environments, and the `request` library loads `fs`,
5282
`net`, and `tls`, but shouldn't need any of them for basic usage because webpack automatically includes
53-
[equivalent libraries](https://www.npmjs.com/package/node-libs-browser)
54-
55-
Ideally, only the specific services used shoud be included, for example:
56-
57-
```js
58-
var ToneAnalyzerV3 = require('ibm-watson/tone-analyzer/v3');
59-
var AssistantV1 = require('ibm-watson/assistant/v1');
60-
```
61-
62-
**Not Recommended**: It's possible to load the entire library, but it is not recommended due to the added file size:
63-
64-
```js
65-
var watson = require('ibm-watson');
66-
```
67-
or
68-
```
69-
const { AssistantV1, ToneAnalyzerV3 } = require('ibm-watson');
70-
```
71-
72-
Additionally, when importing the entire library, the `shebang-loader` package is need and must be configured
73-
in webpack.config.js:
74-
75-
```js
76-
module: {
77-
rules: [{
78-
test: /JSONStream/,
79-
use: 'shebang-loader'
80-
}]
81-
}
82-
```
83+
[equivalent libraries](https://www.npmjs.com/package/node-libs-browser).

examples/webpack/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module.exports = {
55
output: {
66
filename: 'bundle.js',
77
},
8-
// http://webpack.github.io/docs/configuration.html#node
8+
// For versions <5.0.0, http://webpack.github.io/docs/configuration.html#node
99
node: {
1010
fs: 'empty',
1111
net: 'empty',

0 commit comments

Comments
 (0)