From b651913f1483489f3231afbc898e3c597dbeb95a Mon Sep 17 00:00:00 2001 From: FUJI Goro Date: Tue, 11 Feb 2025 10:19:49 +0900 Subject: [PATCH 1/2] implement a tiny polyfill to Symbol.dispose --- src/Decoder.ts | 1 + src/Encoder.ts | 1 + src/utils/symbol.dispose.ts | 11 +++++++++++ 3 files changed, 13 insertions(+) create mode 100644 src/utils/symbol.dispose.ts diff --git a/src/Decoder.ts b/src/Decoder.ts index 55109d2..3a40f9e 100644 --- a/src/Decoder.ts +++ b/src/Decoder.ts @@ -1,3 +1,4 @@ +import "./utils/symbol.dispose"; import { prettyByte } from "./utils/prettyByte"; import { ExtensionCodec, ExtensionCodecType } from "./ExtensionCodec"; import { getInt64, getUint64, UINT32_MAX } from "./utils/int"; diff --git a/src/Encoder.ts b/src/Encoder.ts index af32b33..393c275 100644 --- a/src/Encoder.ts +++ b/src/Encoder.ts @@ -1,3 +1,4 @@ +import "./utils/symbol.dispose"; import { utf8Count, utf8Encode } from "./utils/utf8"; import { ExtensionCodec, ExtensionCodecType } from "./ExtensionCodec"; import { setInt64, setUint64 } from "./utils/int"; diff --git a/src/utils/symbol.dispose.ts b/src/utils/symbol.dispose.ts new file mode 100644 index 0000000..d5d1eba --- /dev/null +++ b/src/utils/symbol.dispose.ts @@ -0,0 +1,11 @@ +// Polyfill to Symbol.dispose + +// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition +if (!Symbol.dispose) { + Object.defineProperty(Symbol, "dispose", { + value: Symbol("dispose"), + writable: false, + enumerable: false, + configurable: false, + }); +} From 9ab0b528eec8d3b507f6fc8304a4a6b2f909200f Mon Sep 17 00:00:00 2001 From: FUJI Goro Date: Tue, 11 Feb 2025 10:27:58 +0900 Subject: [PATCH 2/2] fix esmify for deno --- tools/esmify.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/esmify.ts b/tools/esmify.ts index ce57795..8447c10 100644 --- a/tools/esmify.ts +++ b/tools/esmify.ts @@ -11,6 +11,7 @@ for (const file of files) { // .js => .mjs const content = fs.readFileSync(file).toString("utf-8"); const newContent = content.replace(/\bfrom "(\.\.?\/[^"]+)";/g, 'from "$1.mjs";') + .replace(/\bimport "(\.\.?\/[^"]+)";/g, 'import "$1.mjs";') .replace(/\/\/# sourceMappingURL=(.+)\.js\.map$/, "//# sourceMappingURL=$1.mjs.map"); fs.writeFileSync(fileMjs, newContent);