Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove @parcel/utils dep in @parcel/graph #8630

Merged
merged 1 commit into from Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/core/graph/package.json
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
@@ -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
@@ -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;
}