You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: MIGRATING.md
+49-24
Original file line number
Diff line number
Diff line change
@@ -39,13 +39,13 @@ been using the feature, you can take the following steps:
39
39
40
40
## Webpack
41
41
42
-
Starting with `v4.0.0` of this tool, Webpack is no longer required and is disabled by default for new applications. This can simplify development and result in shorter build times.
42
+
Starting with `v4.0.0` of this tool, webpack is no longer required and is disabled by default for new applications. This can simplify development and result in shorter build times.
43
43
44
-
You may still wish to use Webpack if you need some of the features it provides, e.g., the ability to use loaders, asset modules, module replacement, dynamic imports, etc.
44
+
You may still wish to use webpack if you need some of the features it provides, e.g., the ability to use loaders, asset modules, module replacement, dynamic imports, etc.
45
45
46
-
To migrate away from using Webpack, make the following changes in your `./compute-js` directory:
46
+
To migrate away from using webpack, make the following changes in your `./compute-js` directory:
47
47
48
-
* First, check your `webpack.config.js` file to make sure you aren't actually depending on any custom Webpack features. When you're ready, continue to the next step.
48
+
* First, check your `webpack.config.js` file to make sure you aren't actually depending on any custom webpack features. When you're ready, continue to the next step.
49
49
* Delete `webpack.config.js`.
50
50
* Modify `static-publish.rc.js`:
51
51
* Change the line `module.exports = {` to `const config = {`
@@ -65,27 +65,52 @@ To migrate away from using Webpack, make the following changes in your `./comput
65
65
}
66
66
```
67
67
68
-
If you aren't moving away from Webpack just yet, check that your `webpack.config.js` is up-to-date:
68
+
If you aren't moving away from webpack just yet, check that your `webpack.config.js` is up-to-date. Refer
69
+
to the [default `webpack.config.js` in this package](./resources/webpack.config.js) and add your changes,
70
+
or modify your configuration file using the following steps:
69
71
70
-
* Starting `v3.0.0`, we depend on `v1.0.0` of the `js-compute` library, which provides namespaced exports for Fastly
71
-
features. To use them, you'll need to add a new `externals` array to the bottom if it doesn't exist already, with
72
-
the following entry:
72
+
* To make the resulting bundle easier to debug, it is recommended to set the `devtool` value to `false`.
73
73
74
-
```javascript
75
-
module.exports = {
76
-
/* ... other config ... */
77
-
externals: [
78
-
({request,}, callback) => {
79
-
if (/^fastly:.*$/.test(request)) {
80
-
return callback(null, 'commonjs ' + request);
81
-
}
82
-
callback();
83
-
}
74
+
* The JavaScript SDK automatically adds the named condition `fastly` when resolving dependency packages.
75
+
To match the behavior when bundling with webpack, set `resolve.conditionsNames` to the following:
76
+
```
77
+
resolve: {
78
+
conditionNames: [
79
+
'fastly',
80
+
'...',
81
+
],
84
82
],
85
-
}
86
-
```
83
+
```
84
+
85
+
* Starting `v3.0.0`, we depend on `v1.0.0` of the `js-compute` library, which provides namespaced exports for Fastly
86
+
features. To use them, you'll need to make the following changes to `webpack.config.js`:
87
+
88
+
* Set the `target` value to `false`.
89
+
90
+
* The `output` section should look like this:
91
+
```
92
+
output: {
93
+
filename: "index.js",
94
+
path: path.resolve(__dirname, "bin"),
95
+
chunkFormat: 'commonjs',
96
+
library: {
97
+
type: 'commonjs',
98
+
},
99
+
},
100
+
```
101
+
102
+
* Add a new `externals` array to the bottom if it doesn't exist already. Add the following entry:
103
+
104
+
```javascript
105
+
module.exports = {
106
+
/* ... other config ... */
107
+
externals: [
108
+
/^fastly:.*$/,
109
+
],
110
+
}
111
+
```
87
112
88
-
* Starting `v3.0.0`, we no longer use Webpack static assets to include the contents of static files, and instead [use the
113
+
* Starting `v3.0.0`, we no longer use webpack static assets to include the contents of static files, and instead [use the
0 commit comments