Skip to content

Commit a08c1dd

Browse files
committed
fix: avoid package json module import in runtime code of the plugin.
1 parent 4dcd797 commit a08c1dd

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

zod-plugin/src/runtime.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { globalRegistry, z } from "zod";
2-
import manifest from "../package.json" with { type: "json" };
32
import { setBrand } from "./brand.ts";
43
import { remap } from "./remap.ts";
54

@@ -17,7 +16,8 @@ const labelSetter = function (this: z.ZodDefault, defaultLabel: string) {
1716
return this.meta({ default: defaultLabel });
1817
};
1918

20-
const pluginFlag = Symbol.for(manifest.name);
19+
// eslint-disable-next-line no-restricted-syntax -- substituted by TSDOWN
20+
const pluginFlag = Symbol.for(process.env.TSDOWN_SELF!);
2121

2222
if (!(pluginFlag in globalThis)) {
2323
(globalThis as Record<symbol, unknown>)[pluginFlag] = true;

zod-plugin/tsdown.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { defineConfig } from "tsdown";
2+
import manifest from "./package.json" with { type: "json" };
23

34
export default defineConfig([
45
{
@@ -8,6 +9,9 @@ export default defineConfig([
89
banner: {
910
dts: "import './augmentation.js';",
1011
},
12+
define: {
13+
"process.env.TSDOWN_SELF": `"${manifest.name}"`, // used by pluginFlag
14+
},
1115
},
1216
{
1317
entry: "src/augmentation.ts",

0 commit comments

Comments
 (0)