Skip to content

Commit 3caaa6e

Browse files
authored
Merge pull request #216 from ryoppippi/feature/fix-caching
fix(cache): use `createRequire` to dynamically import `package.json`
2 parents 851b4ea + 89c565c commit 3caaa6e

File tree

1 file changed

+3
-2
lines changed
  • packages/unplugin-typia/src/core

1 file changed

+3
-2
lines changed

packages/unplugin-typia/src/core/cache.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import { accessSync, constants, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
22
import { createHash } from 'node:crypto';
3+
import { createRequire } from 'node:module';
34
import { basename, dirname, join } from 'pathe';
45
import findCacheDirectory from 'find-cache-dir';
5-
import typiaPackageJson from 'typia/package.json' with { type: 'json' };
66
import type { CacheKey, CachePath, Data, FilePath, ID, Source } from './types.js';
77
import { wrap } from './types.js';
88
import { isBun } from './utils.js';
99

10-
const { version: typiaVersion } = typiaPackageJson;
10+
/** get typia version */
11+
const { version: typiaVersion } = createRequire(import.meta.url)('typia/package.json') as typeof import('typia/package.json');
1112

1213
/**
1314
* Cache class

0 commit comments

Comments
 (0)