Skip to content
This repository was archived by the owner on Feb 1, 2022. It is now read-only.

Commit 585dd97

Browse files
authored
fix: avoid array.prototype.flat (#15)
Update tsconfig to reflect that we are using ES2018 (Node 10). Array.prototype.flat is only available in Node 11. Instead of using a polyfill, we will use concat to flatten the array of object arrays
1 parent 9638294 commit 585dd97

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/gatsby-node.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,16 @@ export async function sourceNodes(
5050
};
5151

5252
try {
53-
const objects = await Promise.all(
53+
let objects: Array<any> = await Promise.all(
5454
buckets.map(bucket => listObjects(bucket))
5555
);
56+
// flatten objects
57+
// flat() is not supported in node 10
58+
objects = [].concat(...objects);
5659

5760
// create file nodes
5861
// todo touch nodes if they exist already
59-
objects?.flat().forEach(async object => {
62+
objects?.forEach(async object => {
6063
const { Key, Bucket } = object;
6164
const { region } = awsConfig;
6265

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"compilerOptions": {
3-
"lib": ["ESNext"],
3+
"lib": ["ES2018"],
44
"module": "CommonJS",
55
// support node 10 and newer
66
"target": "ES2018",

0 commit comments

Comments
 (0)