From 224e7b9853608a6d557c05946a3995644d572f13 Mon Sep 17 00:00:00 2001 From: Amol Yadav Date: Sat, 17 Jan 2026 18:51:50 +0530 Subject: [PATCH 1/7] feat: update getDntVersion to support JSR URLs --- lib/utils.test.ts | 1 + lib/utils.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/utils.test.ts b/lib/utils.test.ts index 7a0a0e9..dbac615 100644 --- a/lib/utils.test.ts +++ b/lib/utils.test.ts @@ -38,5 +38,6 @@ Deno.test("getDntVersion", () => { getDntVersion("https://deno.land/x/dnt@20.21.22/mod.ts"), "20.21.22", ); + assertEquals(getDntVersion("https://jsr.io/@deno/dnt/1.2.3/mod.ts"), "1.2.3"); assertEquals(getDntVersion("file:///test/mod.ts"), "dev"); }); diff --git a/lib/utils.ts b/lib/utils.ts index 356450e..f1caa19 100644 --- a/lib/utils.ts +++ b/lib/utils.ts @@ -106,5 +106,5 @@ export function valueToUrl(value: string) { } export function getDntVersion(url = import.meta.url) { - return /\/dnt@([0-9]+\.[0-9]+\.[0-9]+)\//.exec(url)?.[1] ?? "dev"; + return /\/(?:dnt@|@deno\/dnt\/)([0-9]+\.[0-9]+\.[0-9]+)\//.exec(url)?.[1] ?? "dev"; } From 49a0b03c687500a65de5082edfa6e1f00956db3c Mon Sep 17 00:00:00 2001 From: Amol Yadav Date: Sat, 17 Jan 2026 19:10:29 +0530 Subject: [PATCH 2/7] feat: update getDntVersion to support JSR URLs --- lib/utils.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/utils.ts b/lib/utils.ts index f1caa19..17ceaa0 100644 --- a/lib/utils.ts +++ b/lib/utils.ts @@ -106,5 +106,6 @@ export function valueToUrl(value: string) { } export function getDntVersion(url = import.meta.url) { - return /\/(?:dnt@|@deno\/dnt\/)([0-9]+\.[0-9]+\.[0-9]+)\//.exec(url)?.[1] ?? "dev"; + return /\/(?:dnt@|@deno\/dnt\/)([0-9]+\.[0-9]+\.[0-9]+)\//.exec(url)?.[1] ?? + "dev"; } From d6938b02251486ec9bc24016cfda2d63a1176af1 Mon Sep 17 00:00:00 2001 From: Amol Yadav Date: Sat, 17 Jan 2026 19:17:46 +0530 Subject: [PATCH 3/7] added new lint rules --- deno.jsonc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/deno.jsonc b/deno.jsonc index 2d1fed1..f87b154 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -8,7 +8,9 @@ "rules": { "exclude": [ "no-explicit-any", - "camelcase" + "camelcase", + "no-import-prefix", + "no-unversioned-import" ] } }, From 60c1e3e0a0885549b8308a5517f94207d40a8c76 Mon Sep 17 00:00:00 2001 From: Amol Yadav Date: Sat, 17 Jan 2026 22:42:25 +0530 Subject: [PATCH 4/7] feat: add testColor and testRunner options to package.json generation --- lib/package_json.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/package_json.ts b/lib/package_json.ts index ecdc31d..e3a6e1b 100644 --- a/lib/package_json.ts +++ b/lib/package_json.ts @@ -15,6 +15,8 @@ export interface GetPackageJsonOptions { includeTsLib: boolean | undefined; testEnabled: boolean | undefined; shims: ShimOptions; + testColor?: boolean; + testRunner?: boolean; } export function getPackageJson({ @@ -27,6 +29,8 @@ export function getPackageJson({ includeTsLib, testEnabled, shims, + testColor = true, + testRunner = true, }: GetPackageJsonOptions): Record { const finalEntryPoints = transformOutput .main.entryPoints.map((e, i) => ({ @@ -65,7 +69,7 @@ export function getPackageJson({ }; const testDevDependencies = testEnabled ? ({ - ...(!Object.keys(dependencies).includes("picocolors") + ...(testColor && !Object.keys(dependencies).includes("picocolors") ? { "picocolors": "^1.0.0", } @@ -88,7 +92,7 @@ export function getPackageJson({ // override with specified dependencies ...(packageJsonObj.devDependencies ?? {}), }; - const scripts = testEnabled + const scripts = testEnabled && testRunner ? ({ test: "node test_runner.js", // override with specified scripts From f40016c536649db411e66950b201048af49a86b0 Mon Sep 17 00:00:00 2001 From: Amol Yadav Date: Sat, 17 Jan 2026 22:42:50 +0530 Subject: [PATCH 5/7] feat: add globalThis, testColor, and testRunner shim options --- lib/shims.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/shims.ts b/lib/shims.ts index 3cd19ba..5499b74 100644 --- a/lib/shims.ts +++ b/lib/shims.ts @@ -45,6 +45,12 @@ export interface ShimOptions { weakRef?: ShimValue; /** Shim `WebSocket` with the `ws` package (https://www.npmjs.com/package/ws). */ webSocket?: boolean | "dev"; + /** Shim `globalThis` with a proxy that provides Deno globals. */ + globalThis?: ShimValue; + /** Enable colored test output using picocolors. */ + testColor?: boolean; + /** Enable test runner script in package.json. */ + testRunner?: boolean; /** Custom shims to use. */ custom?: Shim[]; /** Custom shims to use only for the test code. */ @@ -58,7 +64,11 @@ export interface DenoShimOptions { test: boolean | "dev"; } -export function shimOptionsToTransformShims(options: ShimOptions) { +export function shimOptionsToTransformShims(options: ShimOptions): { + shims: Shim[]; + testShims: Shim[]; + useGlobalThisShim: boolean; +} { const shims: Shim[] = []; const testShims: Shim[] = []; @@ -84,9 +94,12 @@ export function shimOptionsToTransformShims(options: ShimOptions) { testShims.push(...options.customDev); } + const useGlobalThisShim = options.globalThis !== false; + return { shims, testShims, + useGlobalThisShim, }; function add(option: boolean | "dev" | undefined, getShim: () => Shim) { From e423f8bebdc93aa2f335ecd1615bc57e98346505 Mon Sep 17 00:00:00 2001 From: Amol Yadav Date: Sat, 17 Jan 2026 22:43:22 +0530 Subject: [PATCH 6/7] feat: pass useGlobalThisShim and new options to transform --- mod.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mod.ts b/mod.ts index 29fc8e0..5929f23 100644 --- a/mod.ts +++ b/mod.ts @@ -539,6 +539,8 @@ export async function build(options: BuildOptions): Promise { includeDeclarations: options.declaration === "separate", includeTsLib: options.compilerOptions?.importHelpers, shims: options.shims, + testColor: options.shims.testColor ?? true, + testRunner: options.shims.testRunner ?? true, }); writeFile( path.join(options.outDir, "package.json"), @@ -574,7 +576,9 @@ export async function build(options: BuildOptions): Promise { } async function transformEntryPoints(): Promise { - const { shims, testShims } = shimOptionsToTransformShims(options.shims); + const { shims, testShims, useGlobalThisShim } = shimOptionsToTransformShims( + options.shims, + ); return transform({ entryPoints: entryPoints.map((e) => e.path), testEntryPoints: options.test @@ -591,6 +595,7 @@ export async function build(options: BuildOptions): Promise { importMap: options.importMap, configFile: options.configFile, cwd: path.toFileUrl(cwd).toString(), + useGlobalThisShim, }); } From b3f0b6428dea1cf0ca09793b5eb1853c0014bbf1 Mon Sep 17 00:00:00 2001 From: Amol Yadav Date: Sat, 17 Jan 2026 22:43:41 +0530 Subject: [PATCH 7/7] feat: add useGlobalThisShim flag to TransformOptions --- transform.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/transform.ts b/transform.ts index 2e2d726..dcf60e8 100644 --- a/transform.ts +++ b/transform.ts @@ -76,6 +76,7 @@ export interface TransformOptions { importMap?: string; configFile?: string; cwd: string; + useGlobalThisShim?: boolean; } /** Dependency in a package.json file. */