Skip to content

Commit

Permalink
fix: remove @parcel/utils dep in @parcel/graph (#8630)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahaoboy authored Nov 17, 2022
1 parent c3bbe0a commit 711ae18
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
1 change: 0 additions & 1 deletion packages/core/graph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"node": ">= 12.0.0"
},
"dependencies": {
"@parcel/utils": "2.8.0",
"nullthrows": "^1.1.1"
}
}
2 changes: 1 addition & 1 deletion packages/core/graph/src/AdjacencyList.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @flow
import assert from 'assert';
import nullthrows from 'nullthrows';
import {SharedBuffer} from '@parcel/utils';
import {SharedBuffer} from './shared-buffer';
import {fromNodeId, toNodeId} from './types';
import {ALL_EDGE_TYPES, type NullEdgeType, type AllEdgeTypes} from './Graph';
import type {NodeId} from './types';
Expand Down
24 changes: 24 additions & 0 deletions packages/core/graph/src/shared-buffer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// @flow
/* global MessageChannel:readonly */
// Copy from @parcel/utils to fix: https://github.com/stackblitz/core/issues/1855
export let SharedBuffer: Class<ArrayBuffer> | Class<SharedArrayBuffer>;

// $FlowFixMe[prop-missing]
if (process.browser) {
SharedBuffer = ArrayBuffer;
// Safari has removed the constructor
if (typeof SharedArrayBuffer !== 'undefined') {
let channel = new MessageChannel();
try {
// Firefox might throw when sending the Buffer over a MessagePort
channel.port1.postMessage(new SharedArrayBuffer(0));
SharedBuffer = SharedArrayBuffer;
} catch (_) {
// NOOP
}
channel.port1.close();
channel.port2.close();
}
} else {
SharedBuffer = SharedArrayBuffer;
}

0 comments on commit 711ae18

Please sign in to comment.