aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/v8.exports.js
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2023-04-01 21:13:27 -0700
committerGravatar GitHub <noreply@github.com> 2023-04-01 21:13:27 -0700
commitfcd8b828644cc3cf2bd46bbfc0f6b90789d5dba2 (patch)
tree075ad9fc3375a56b71da4ce6625419e5dd10cdba /src/bun.js/v8.exports.js
parent63d138b0466765e012aaa216ab684b2d39888e64 (diff)
downloadbun-fcd8b828644cc3cf2bd46bbfc0f6b90789d5dba2.tar.gz
bun-fcd8b828644cc3cf2bd46bbfc0f6b90789d5dba2.tar.zst
bun-fcd8b828644cc3cf2bd46bbfc0f6b90789d5dba2.zip
Add stubs for missing node builtins (#2534)
* Stub `node:v8` * Stub `node:trace_events` * Stub `node:repl` * Stub `node:inspector` * Stub `node:http2` * Stub `node:diagnostics_channel` * Stub `node:dgram` * Stub `node:cluster` * Link stubs * cleanup * Clean up the test * Implement `node:vm` stub * Cleanup `v8` module stub * Add missing `promises` export to node:stream * Implement `node:stream/promise` * Implement `node:assert/strict` * cleanup * better errors * Increaase timeout * Update inspector.exports.js * Make the version consistent * Implement `process.binding("constants")` * Update runner.node.mjs --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'src/bun.js/v8.exports.js')
-rw-r--r--src/bun.js/v8.exports.js166
1 files changed, 166 insertions, 0 deletions
diff --git a/src/bun.js/v8.exports.js b/src/bun.js/v8.exports.js
new file mode 100644
index 000000000..4ac85fd3b
--- /dev/null
+++ b/src/bun.js/v8.exports.js
@@ -0,0 +1,166 @@
+// This is a stub! None of this is actually implemented yet.
+
+class TODO extends Error {
+ constructor(messageName) {
+ const message = messageName
+ ? `node:v8 ${messageName} is not implemented yet in Bun. `
+ : `node:v8 is not implemented yet in Bun`;
+ super(message);
+ this.name = "TODO";
+ }
+}
+
+function hideFromStack(fns) {
+ for (const fn of fns) {
+ Object.defineProperty(fn, "name", {
+ value: "::bunternal::",
+ });
+ }
+}
+
+function notimpl(message) {
+ throw new TODO(message);
+}
+
+class Deserializer {
+ constructor() {
+ notimpl();
+ }
+}
+class Serializer {
+ constructor() {
+ notimpl();
+ }
+}
+class DefaultDeserializer extends Deserializer {}
+class DefaultSerializer extends Serializer {}
+class GCProfiler {
+ constructor() {
+ notimpl();
+ }
+}
+
+function cachedDataVersionTag() {
+ notimpl("cachedDataVersionTag");
+}
+function getHeapSnapshot() {
+ notimpl("getHeapSnapshot");
+}
+function getHeapStatistics() {
+ notimpl("getHeapStatistics");
+}
+function getHeapSpaceStatistics() {
+ notimpl("getHeapSpaceStatistics");
+}
+function getHeapCodeStatistics() {
+ notimpl("getHeapCodeStatistics");
+}
+function setFlagsFromString() {
+ notimpl("setFlagsFromString");
+}
+function deserialize() {
+ notimpl("deserialize");
+}
+function takeCoverage() {
+ notimpl("takeCoverage");
+}
+function stopCoverage() {
+ notimpl("stopCoverage");
+}
+function serialize() {
+ notimpl("serialize");
+}
+function writeHeapSnapshot() {
+ notimpl("writeHeapSnapshot");
+}
+function setHeapSnapshotNearHeapLimit() {
+ notimpl("setHeapSnapshotNearHeapLimit");
+}
+const promiseHooks = {
+ createHook: () => {
+ notimpl("createHook");
+ },
+ onInit: () => {
+ notimpl("onInit");
+ },
+ onBefore: () => {
+ notimpl("onBefore");
+ },
+ onAfter: () => {
+ notimpl("onAfter");
+ },
+ onSettled: () => {
+ notimpl("onSettled");
+ },
+ },
+ startupSnapshot = {
+ addDeserializeCallback: () => notimpl("addDeserializeCallback"),
+ addSerializeCallback: () => notimpl("addSerializeCallback"),
+ setDeserializeMainFunction: () => notimpl("setDeserializeMainFunction"),
+ isBuildingSnapshot: () => notimpl("isBuildingSnapshot"),
+ };
+
+const defaultObject = {
+ cachedDataVersionTag,
+ getHeapSnapshot,
+ getHeapStatistics,
+ getHeapSpaceStatistics,
+ getHeapCodeStatistics,
+ setFlagsFromString,
+ deserialize,
+ takeCoverage,
+ stopCoverage,
+ serialize,
+ writeHeapSnapshot,
+ setHeapSnapshotNearHeapLimit,
+ promiseHooks,
+ startupSnapshot,
+ Deserializer,
+ Serializer,
+ [Symbol.for("CommonJS")]: 0,
+};
+
+export {
+ cachedDataVersionTag,
+ getHeapSnapshot,
+ getHeapStatistics,
+ getHeapSpaceStatistics,
+ getHeapCodeStatistics,
+ setFlagsFromString,
+ deserialize,
+ takeCoverage,
+ stopCoverage,
+ serialize,
+ writeHeapSnapshot,
+ setHeapSnapshotNearHeapLimit,
+ promiseHooks,
+ startupSnapshot,
+ Deserializer,
+ Serializer,
+ DefaultDeserializer,
+ DefaultSerializer,
+ GCProfiler,
+ defaultObject as default,
+};
+
+hideFromStack([
+ TODO.prototype.constructor,
+ notimpl,
+ cachedDataVersionTag,
+ getHeapSnapshot,
+ getHeapStatistics,
+ getHeapSpaceStatistics,
+ getHeapCodeStatistics,
+ setFlagsFromString,
+ deserialize,
+ takeCoverage,
+ stopCoverage,
+ serialize,
+ writeHeapSnapshot,
+ setHeapSnapshotNearHeapLimit,
+ Deserializer,
+ Serializer,
+ DefaultDeserializer,
+ DefaultSerializer,
+ GCProfiler,
+]);