Skip to content

Commit 90204e8

Browse files
authored
Merge pull request #370 from cwillisf/polyfill-fetch-in-node
fix: polyfill 'fetch' for Node target
2 parents d331232 + 4796416 commit 90204e8

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

test/integration/download-known-assets.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
const md5 = require('js-md5');
22
const test = require('tap').test;
3-
// Polyfill the fetch API
4-
global.fetch = require('node-fetch');
53

64
const ScratchStorage = require('../../dist/node/scratch-storage');
75

@@ -18,6 +16,7 @@ test('constructor', t => {
1816
* @typedef {object} AssetTestInfo
1917
* @property {AssetType} type - The type of the asset.
2018
* @property {string} id - The asset's unique ID.
19+
* @property {string} md5 - The asset's MD5 hash.
2120
* @property {DataFormat} [ext] - Optional: the asset's data format / file extension.
2221
*/
2322
const testAssets = [

webpack.config.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const path = require('path');
2+
const {ProvidePlugin} = require('webpack');
23
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
34

45
const base = {
@@ -64,6 +65,11 @@ module.exports = [
6465
'js-md5': true,
6566
'localforage': true,
6667
'text-encoding': true
67-
}
68+
},
69+
plugins: [
70+
new ProvidePlugin({
71+
fetch: ['node-fetch', 'default']
72+
})
73+
]
6874
})
6975
];

0 commit comments

Comments
 (0)