22
33const path = require ( 'node:path' )
44
5- const semver = require ( 'semver' )
6-
75const registryConstants = require ( '@socketsecurity/registry/lib/constants' )
86const {
97 kInternalsSymbol,
@@ -14,8 +12,6 @@ const {
1412const ROLLUP_ENTRY_SUFFIX = '?commonjs-entry'
1513const ROLLUP_EXTERNAL_SUFFIX = '?commonjs-external'
1614const SLASH_NODE_MODULES_SLASH = '/node_modules/'
17- const SUPPORTS_SYNC_ESM = semver . satisfies ( process . versions . node , '>=22.12' )
18- const DIST_TYPE = SUPPORTS_SYNC_ESM ? 'module-sync' : 'require'
1915
2016const rootPath = path . resolve ( __dirname , '..' )
2117const rootConfigPath = path . join ( rootPath , '.config' )
@@ -25,19 +21,22 @@ const rootSrcPath = path.join(rootPath, 'src')
2521
2622const babelConfigPath = path . join ( rootConfigPath , 'babel.config.js' )
2723const depStatsPath = path . join ( rootPath , '.dep-stats.json' )
28- const distPath = path . join ( rootDistPath , DIST_TYPE )
2924const tsconfigPath = path . join ( rootConfigPath , 'tsconfig.rollup.json' )
3025
26+ const LAZY_DIST_TYPE = ( ) =>
27+ registryConstants . SUPPORTS_NODE_REQUIRE_MODULE ? 'module-sync' : 'require'
28+
29+ const lazyDistPath = ( ) => path . join ( rootDistPath , constants . DIST_TYPE )
30+
3131const constants = createConstantsObject (
3232 {
33- DIST_TYPE ,
33+ DIST_TYPE : undefined ,
3434 ROLLUP_ENTRY_SUFFIX ,
3535 ROLLUP_EXTERNAL_SUFFIX ,
3636 SLASH_NODE_MODULES_SLASH ,
37- SUPPORTS_SYNC_ESM ,
3837 babelConfigPath,
3938 depStatsPath,
40- distPath,
39+ distPath : undefined ,
4140 rootConfigPath,
4241 rootDistPath,
4342 rootPackageJsonPath,
@@ -46,6 +45,10 @@ const constants = createConstantsObject(
4645 tsconfigPath
4746 } ,
4847 {
48+ getters : {
49+ DIST_TYPE : LAZY_DIST_TYPE ,
50+ distPath : lazyDistPath
51+ } ,
4952 mixin : registryConstants
5053 }
5154)
0 commit comments