@dr.pogodin/react-utils 1.56.1 → 1.56.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/development/server/utils/modules.js +19 -14
- package/build/development/server/utils/modules.js.map +1 -1
- package/build/production/server/utils/modules.js +3 -3
- package/build/production/server/utils/modules.js.map +1 -1
- package/build/web/server/utils/modules.js +3 -3
- package/build/web/server/utils/modules.js.map +1 -1
- package/package.json +2 -2
|
@@ -7,7 +7,6 @@ import { existsSync, readFileSync, statSync } from "node:fs";
|
|
|
7
7
|
import { createRequire, registerHooks } from "node:module";
|
|
8
8
|
import { basename, dirname } from "node:path";
|
|
9
9
|
import { fileURLToPath } from "node:url";
|
|
10
|
-
const CANDIDATE_EXTENSIONS = [".js", ".jsx", ".ts", ".tsx"];
|
|
11
10
|
const require = createRequire(import.meta.url); /**
|
|
12
11
|
* It looks like, as of Babel v8, @babel/node does not quite work with ES module
|
|
13
12
|
* codebase. This function registers a Node module API hook that customizes ES
|
|
@@ -48,6 +47,14 @@ export function registerBabelLoader({
|
|
|
48
47
|
return next(url, context);
|
|
49
48
|
}
|
|
50
49
|
});
|
|
50
|
+
}
|
|
51
|
+
const CANDIDATE_EXTENSIONS = [".js", ".jsx", ".ts", ".tsx"];
|
|
52
|
+
function resolveExtension(base) {
|
|
53
|
+
for (const ext of CANDIDATE_EXTENSIONS) {
|
|
54
|
+
const path = base + ext;
|
|
55
|
+
if (existsSync(path)) return path;
|
|
56
|
+
}
|
|
57
|
+
return null;
|
|
51
58
|
} /**
|
|
52
59
|
* Registers a Node module API hook that customizes ES module resolution
|
|
53
60
|
* to make mandatory file extensions optional.
|
|
@@ -55,21 +62,19 @@ export function registerBabelLoader({
|
|
|
55
62
|
export function registerResolver() {
|
|
56
63
|
registerHooks({
|
|
57
64
|
resolve(specifier, context, next) {
|
|
58
|
-
let
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
break;
|
|
69
|
-
}
|
|
65
|
+
let path = specifier;
|
|
66
|
+
const isAbsolute = path.startsWith("/");
|
|
67
|
+
const isRelative = path.startsWith(".");
|
|
68
|
+
if (isAbsolute || isRelative) {
|
|
69
|
+
if (isRelative) path = new URL(path, context.parentURL).pathname;
|
|
70
|
+
const stat = statSync(path, {
|
|
71
|
+
throwIfNoEntry: false
|
|
72
|
+
});
|
|
73
|
+
if (!stat?.isFile()) {
|
|
74
|
+
path = resolveExtension(path) ?? (stat?.isDirectory() ? resolveExtension(`${path}/index`) : null) ?? specifier;
|
|
70
75
|
}
|
|
71
76
|
}
|
|
72
|
-
return next(
|
|
77
|
+
return next(path, context);
|
|
73
78
|
}
|
|
74
79
|
});
|
|
75
80
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modules.js","names":[],"sources":["../../../../src/server/utils/modules.ts"],"sourcesContent":["// TODO: It makes sense to move these to more generic JS Utils,\n// but it will probably require some rework of exports there, as these\n// are strictly for NodeJS environment, while current JS Utils are\n// generic JavaScript, environment-agnostic... thus, for now let's\n// keep it here, until we really need these outside a React app.\n\nimport { existsSync, readFileSync, statSync } from 'node:fs';\nimport { type LoadFnOutput, createRequire, registerHooks } from 'node:module';\nimport { basename, dirname } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport type * as BabelCore from '@babel/core';\n\nconst
|
|
1
|
+
{"version":3,"file":"modules.js","names":[],"sources":["../../../../src/server/utils/modules.ts"],"sourcesContent":["// TODO: It makes sense to move these to more generic JS Utils,\n// but it will probably require some rework of exports there, as these\n// are strictly for NodeJS environment, while current JS Utils are\n// generic JavaScript, environment-agnostic... thus, for now let's\n// keep it here, until we really need these outside a React app.\n\nimport { existsSync, readFileSync, statSync } from 'node:fs';\nimport { type LoadFnOutput, createRequire, registerHooks } from 'node:module';\nimport { basename, dirname } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport type * as BabelCore from '@babel/core';\n\nconst require = createRequire(import.meta.url);\n\ntype RegisterBabelLoaderArgT = {\n envName?: string;\n root?: string;\n};\n\n/**\n * It looks like, as of Babel v8, @babel/node does not quite work with ES module\n * codebase. This function registers a Node module API hook that customizes ES\n * module loading, to run Babel transformation on them.\n *{(\n * BEWARE: It is intended for development environments only.\n */\nexport function registerBabelLoader({\n envName = 'development',\n root = process.cwd(),\n}: RegisterBabelLoaderArgT = {}): void {\n // eslint-disable-next-line import/no-extraneous-dependencies\n const { transformSync } = require('@babel/core') as typeof BabelCore;\n\n const cache = new Map<string, LoadFnOutput>();\n\n registerHooks({\n load(url, context, next) {\n const cached = cache.get(url);\n if (cached !== undefined) return cached;\n\n if (\n url.startsWith('file://')\n && !url.includes('/node_modules/')\n && !url.includes('/config/babel/')\n && url.match(/.(js|jsx|svg|ts|tsx)$/)\n ) {\n const path = fileURLToPath(url);\n const source = readFileSync(path, 'utf8');\n\n const transformed = transformSync(source, {\n cwd: dirname(path),\n envName,\n filename: basename(path),\n root,\n });\n\n const res: LoadFnOutput = {\n format: 'module',\n shortCircuit: true,\n source: transformed?.code ?? '',\n };\n\n cache.set(url, res);\n return res;\n }\n\n return next(url, context);\n },\n });\n}\n\nconst CANDIDATE_EXTENSIONS = [\n '.js',\n '.jsx',\n '.ts',\n '.tsx',\n];\n\nfunction resolveExtension(base: string): null | string {\n for (const ext of CANDIDATE_EXTENSIONS) {\n const path = base + ext;\n if (existsSync(path)) return path;\n }\n\n return null;\n}\n\n/**\n * Registers a Node module API hook that customizes ES module resolution\n * to make mandatory file extensions optional.\n */\nexport function registerResolver(): void {\n registerHooks({\n resolve(specifier, context, next) {\n let path = specifier;\n\n const isAbsolute = path.startsWith('/');\n const isRelative = path.startsWith('.');\n\n if (isAbsolute || isRelative) {\n if (isRelative) path = new URL(path, context.parentURL).pathname;\n const stat = statSync(path, { throwIfNoEntry: false });\n if (!stat?.isFile()) {\n path = resolveExtension(path)\n ?? (stat?.isD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AAgB,CAAC,IAAI,CAAC,KACvB,IAAI,EAAE,WAAW,CAAC,CAAC,GAAG,gBAAgB,CAAC,GAAG,IAAI,QAAQ,CAAC,GAAG,IAAI,CAAC,IAChE,SAAS;QAChB;MACF;MAEA,OAAO,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC;IAC5B;EACF,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
// are strictly for NodeJS environment, while current JS Utils are
|
|
4
4
|
// generic JavaScript, environment-agnostic... thus, for now let's
|
|
5
5
|
// keep it here, until we really need these outside a React app.
|
|
6
|
-
import{existsSync,readFileSync,statSync}from"node:fs";import{createRequire,registerHooks}from"node:module";import{basename,dirname}from"node:path";import{fileURLToPath}from"node:url";const
|
|
6
|
+
import{existsSync,readFileSync,statSync}from"node:fs";import{createRequire,registerHooks}from"node:module";import{basename,dirname}from"node:path";import{fileURLToPath}from"node:url";const require=createRequire(import.meta.url);/**
|
|
7
7
|
* It looks like, as of Babel v8, @babel/node does not quite work with ES module
|
|
8
8
|
* codebase. This function registers a Node module API hook that customizes ES
|
|
9
9
|
* module loading, to run Babel transformation on them.
|
|
10
10
|
*{(
|
|
11
11
|
* BEWARE: It is intended for development environments only.
|
|
12
12
|
*/export function registerBabelLoader({envName="development",root=process.cwd()}={}){// eslint-disable-next-line import/no-extraneous-dependencies
|
|
13
|
-
const{transformSync}=require("@babel/core");const cache=new Map;registerHooks({load(url,context,next){const cached=cache.get(url);if(cached!==undefined)return cached;if(url.startsWith("file://")&&!url.includes("/node_modules/")&&!url.includes("/config/babel/")&&url.match(/.(js|jsx|svg|ts|tsx)$/)){const path=fileURLToPath(url);const source=readFileSync(path,"utf8");const transformed=transformSync(source,{cwd:dirname(path),envName,filename:basename(path),root});const res={format:"module",shortCircuit:true,source:transformed?.code??""};cache.set(url,res);return res;}return next(url,context);}});}/**
|
|
13
|
+
const{transformSync}=require("@babel/core");const cache=new Map;registerHooks({load(url,context,next){const cached=cache.get(url);if(cached!==undefined)return cached;if(url.startsWith("file://")&&!url.includes("/node_modules/")&&!url.includes("/config/babel/")&&url.match(/.(js|jsx|svg|ts|tsx)$/)){const path=fileURLToPath(url);const source=readFileSync(path,"utf8");const transformed=transformSync(source,{cwd:dirname(path),envName,filename:basename(path),root});const res={format:"module",shortCircuit:true,source:transformed?.code??""};cache.set(url,res);return res;}return next(url,context);}});}const CANDIDATE_EXTENSIONS=[".js",".jsx",".ts",".tsx"];function resolveExtension(base){for(const ext of CANDIDATE_EXTENSIONS){const path=base+ext;if(existsSync(path))return path;}return null;}/**
|
|
14
14
|
* Registers a Node module API hook that customizes ES module resolution
|
|
15
15
|
* to make mandatory file extensions optional.
|
|
16
|
-
*/export function registerResolver(){registerHooks({resolve(specifier,context,next){let
|
|
16
|
+
*/export function registerResolver(){registerHooks({resolve(specifier,context,next){let path=specifier;const isAbsolute=path.startsWith("/");const isRelative=path.startsWith(".");if(isAbsolute||isRelative){if(isRelative)path=new URL(path,context.parentURL).pathname;const stat=statSync(path,{throwIfNoEntry:false});if(!stat?.isFile()){path=resolveExtension(path)??(stat?.isDirectory()?resolveExtension(`${path}/index`):null)??specifier;}}return next(path,context);}});}
|
|
17
17
|
//# sourceMappingURL=modules.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modules.js","names":[],"sources":["../../../../src/server/utils/modules.ts"],"sourcesContent":["// TODO: It makes sense to move these to more generic JS Utils,\n// but it will probably require some rework of exports there, as these\n// are strictly for NodeJS environment, while current JS Utils are\n// generic JavaScript, environment-agnostic... thus, for now let's\n// keep it here, until we really need these outside a React app.\n\nimport { existsSync, readFileSync, statSync } from 'node:fs';\nimport { type LoadFnOutput, createRequire, registerHooks } from 'node:module';\nimport { basename, dirname } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport type * as BabelCore from '@babel/core';\n\nconst
|
|
1
|
+
{"version":3,"file":"modules.js","names":[],"sources":["../../../../src/server/utils/modules.ts"],"sourcesContent":["// TODO: It makes sense to move these to more generic JS Utils,\n// but it will probably require some rework of exports there, as these\n// are strictly for NodeJS environment, while current JS Utils are\n// generic JavaScript, environment-agnostic... thus, for now let's\n// keep it here, until we really need these outside a React app.\n\nimport { existsSync, readFileSync, statSync } from 'node:fs';\nimport { type LoadFnOutput, createRequire, registerHooks } from 'node:module';\nimport { basename, dirname } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport type * as BabelCore from '@babel/core';\n\nconst require = createRequire(import.meta.url);\n\ntype RegisterBabelLoaderArgT = {\n envName?: string;\n root?: string;\n};\n\n/**\n * It looks like, as of Babel v8, @babel/node does not quite work with ES module\n * codebase. This function registers a Node module API hook that customizes ES\n * module loading, to run Babel transformation on them.\n *{(\n * BEWARE: It is intended for development environments only.\n */\nexport function registerBabelLoader({\n envName = 'development',\n root = process.cwd(),\n}: RegisterBabelLoaderArgT = {}): void {\n // eslint-disable-next-line import/no-extraneous-dependencies\n const { transformSync } = require('@babel/core') as typeof BabelCore;\n\n const cache = new Map<string, LoadFnOutput>();\n\n registerHooks({\n load(url, context, next) {\n const cached = cache.get(url);\n if (cached !== undefined) return cached;\n\n if (\n url.startsWith('file://')\n && !url.includes('/node_modules/')\n && !url.includes('/config/babel/')\n && url.match(/.(js|jsx|svg|ts|tsx)$/)\n ) {\n const path = fileURLToPath(url);\n const source = readFileSync(path, 'utf8');\n\n const transformed = transformSync(source, {\n cwd: dirname(path),\n envName,\n filename: basename(path),\n root,\n });\n\n const res: LoadFnOutput = {\n format: 'module',\n shortCircuit: true,\n source: transformed?.code ?? '',\n };\n\n cache.set(url, res);\n return res;\n }\n\n return next(url, context);\n },\n });\n}\n\nconst CANDIDATE_EXTENSIONS = [\n '.js',\n '.jsx',\n '.ts',\n '.tsx',\n];\n\nfunction resolveExtension(base: string): null | string {\n for (const ext of CANDIDATE_EXTENSIONS) {\n const path = base + ext;\n if (existsSync(path)) return path;\n }\n\n return null;\n}\n\n/**\n * Registers a Node module API hook that customizes ES module resolution\n * to make mandatory file extensions optional.\n */\nexport function registerResolver(): void {\n registerHooks({\n resolve(specifier, context, next) {\n let path = specifier;\n\n const isAbsolute = path.startsWith('/');\n const isRelative = path.startsWith('.');\n\n if (isAbsolute || isRelative) {\n if (isRelative) path = new URL(path, context.parentURL).pathname;\n const stat = statSync(path, { throwIfNoEntry: false });\n if (!stat?.isFile()) {\n path = resolveExtension(path)\n ?? (stat?.isDirectory() ? resolveExtension(`${path}/index`) : null)\n ?? specifier;\n }\n }\n\n return next(path, context);\n },\n });\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA,OAAS,UAAU,CAAE,YAAY,CAAE,QAAQ,KAAQ,SAAS,CAC5D,OAA4B,aAAa,CAAE,aAAa,KAAQ,aAAa,CAC7E,OAAS,QAAQ,CAAE,OAAO,KAAQ,WAAW,CAC7C,OAAS,aAAa,KAAQ,UAAU,CAIxC,KAAM,QAAO,CAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAO9C;AACA;AACA;AACA;AACA;AACA;AACA,GACA,MAAO,SAAS,oBAAmB,CAAC,CAClC,OAAO,CAAG,aAAa,CACvB,IAAI,CAAG,OAAO,CAAC,GAAG,CAAC,CACI,CAAC,CAAG,CAAC,CAAC,CAAQ,CACrC;AACA,KAAM,CAAE,aAAc,CAAC,CAAG,OAAO,CAAC,aAAa,CAAqB,CAEpE,KAAM,MAAK,CAAG,GAAI,IAA2B,CAE7C,aAAa,CAAC,CACZ,IAAI,CAAC,GAAG,CAAE,OAAO,CAAE,IAAI,CAAE,CACvB,KAAM,OAAM,CAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAC7B,GAAI,MAAM,GAAK,SAAS,CAAE,MAAO,OAAM,CAEvC,GACE,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,EACtB,CAAC,GAAG,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAC/B,CAAC,GAAG,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EA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AE,IAAI,CAAG,GAAI,IAAG,CAAC,IAAI,CAAE,OAAO,CAAC,SAAS,CAAC,CAAC,QAAQ,CAChE,KAAM,KAAI,CAAG,QAAQ,CAAC,IAAI,CAAE,CAAE,cAAc,CAAE,KAAM,CAAC,CAAC,CACtD,GAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAE,CACnB,IAAI,CAAG,gBAAgB,CAAC,IAAI,CAAC,GACvB,IAAI,EAAE,WAAW,CAAC,CAAC,CAAG,gBAAgB,CAAC,GAAG,IAAI,QAAQ,CAAC,CAAG,IAAI,CAAC,EAChE,SAAS,CAChB,CACF,CAEA,MAAO,KAAI,CAAC,IAAI,CAAE,OAAO,CAAC,CAC5B,CACF,CAAC,CAAC,CACJ","ignoreList":[]}
|
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
// are strictly for NodeJS environment, while current JS Utils are
|
|
4
4
|
// generic JavaScript, environment-agnostic... thus, for now let's
|
|
5
5
|
// keep it here, until we really need these outside a React app.
|
|
6
|
-
import{existsSync,readFileSync,statSync}from"node:fs";import{createRequire,registerHooks}from"node:module";import{basename,dirname}from"node:path";import{fileURLToPath}from"node:url";const
|
|
6
|
+
import{existsSync,readFileSync,statSync}from"node:fs";import{createRequire,registerHooks}from"node:module";import{basename,dirname}from"node:path";import{fileURLToPath}from"node:url";const require=createRequire(import.meta.url);/**
|
|
7
7
|
* It looks like, as of Babel v8, @babel/node does not quite work with ES module
|
|
8
8
|
* codebase. This function registers a Node module API hook that customizes ES
|
|
9
9
|
* module loading, to run Babel transformation on them.
|
|
10
10
|
*{(
|
|
11
11
|
* BEWARE: It is intended for development environments only.
|
|
12
12
|
*/export function registerBabelLoader({envName="development",root=process.cwd()}={}){// eslint-disable-next-line import/no-extraneous-dependencies
|
|
13
|
-
const{transformSync}=require("@babel/core");const cache=new Map;registerHooks({load(url,context,next){const cached=cache.get(url);if(cached!==undefined)return cached;if(url.startsWith("file://")&&!url.includes("/node_modules/")&&!url.includes("/config/babel/")&&url.match(/.(js|jsx|svg|ts|tsx)$/)){const path=fileURLToPath(url);const source=readFileSync(path,"utf8");const transformed=transformSync(source,{cwd:dirname(path),envName,filename:basename(path),root});const res={format:"module",shortCircuit:true,source:transformed?.code??""};cache.set(url,res);return res;}return next(url,context);}});}/**
|
|
13
|
+
const{transformSync}=require("@babel/core");const cache=new Map;registerHooks({load(url,context,next){const cached=cache.get(url);if(cached!==undefined)return cached;if(url.startsWith("file://")&&!url.includes("/node_modules/")&&!url.includes("/config/babel/")&&url.match(/.(js|jsx|svg|ts|tsx)$/)){const path=fileURLToPath(url);const source=readFileSync(path,"utf8");const transformed=transformSync(source,{cwd:dirname(path),envName,filename:basename(path),root});const res={format:"module",shortCircuit:true,source:transformed?.code??""};cache.set(url,res);return res;}return next(url,context);}});}const CANDIDATE_EXTENSIONS=[".js",".jsx",".ts",".tsx"];function resolveExtension(base){for(const ext of CANDIDATE_EXTENSIONS){const path=base+ext;if(existsSync(path))return path;}return null;}/**
|
|
14
14
|
* Registers a Node module API hook that customizes ES module resolution
|
|
15
15
|
* to make mandatory file extensions optional.
|
|
16
|
-
*/export function registerResolver(){registerHooks({resolve(specifier,context,next){let
|
|
16
|
+
*/export function registerResolver(){registerHooks({resolve(specifier,context,next){let path=specifier;const isAbsolute=path.startsWith("/");const isRelative=path.startsWith(".");if(isAbsolute||isRelative){if(isRelative)path=new URL(path,context.parentURL).pathname;const stat=statSync(path,{throwIfNoEntry:false});if(!stat?.isFile()){path=resolveExtension(path)??(stat?.isDirectory()?resolveExtension(`${path}/index`):null)??specifier;}}return next(path,context);}});}
|
|
17
17
|
//# sourceMappingURL=modules.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modules.js","names":[],"sources":["../../../../src/server/utils/modules.ts"],"sourcesContent":["// TODO: It makes sense to move these to more generic JS Utils,\n// but it will probably require some rework of exports there, as these\n// are strictly for NodeJS environment, while current JS Utils are\n// generic JavaScript, environment-agnostic... thus, for now let's\n// keep it here, until we really need these outside a React app.\n\nimport { existsSync, readFileSync, statSync } from 'node:fs';\nimport { type LoadFnOutput, createRequire, registerHooks } from 'node:module';\nimport { basename, dirname } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport type * as BabelCore from '@babel/core';\n\nconst
|
|
1
|
+
{"version":3,"file":"modules.js","names":[],"sources":["../../../../src/server/utils/modules.ts"],"sourcesContent":["// TODO: It makes sense to move these to more generic JS Utils,\n// but it will probably require some rework of exports there, as these\n// are strictly for NodeJS environment, while current JS Utils are\n// generic JavaScript, environment-agnostic... thus, for now let's\n// keep it here, until we really need these outside a React app.\n\nimport { existsSync, readFileSync, statSync } from 'node:fs';\nimport { type LoadFnOutput, createRequire, registerHooks } from 'node:module';\nimport { basename, dirname } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport type * as BabelCore from '@babel/core';\n\nconst require = createRequire(import.meta.url);\n\ntype RegisterBabelLoaderArgT = {\n envName?: string;\n root?: string;\n};\n\n/**\n * It looks like, as of Babel v8, @babel/node does not quite work with ES module\n * codebase. This function registers a Node module API hook that customizes ES\n * module loading, to run Babel transformation on them.\n *{(\n * BEWARE: It is intended for development environments only.\n */\nexport function registerBabelLoader({\n envName = 'development',\n root = process.cwd(),\n}: RegisterBabelLoaderArgT = {}): void {\n // eslint-disable-next-line import/no-extraneous-dependencies\n const { transformSync } = require('@babel/core') as typeof BabelCore;\n\n const cache = new Map<string, LoadFnOutput>();\n\n registerHooks({\n load(url, context, next) {\n const cached = cache.get(url);\n if (cached !== undefined) return cached;\n\n if (\n url.startsWith('file://')\n && !url.includes('/node_modules/')\n && !url.includes('/config/babel/')\n && url.match(/.(js|jsx|svg|ts|tsx)$/)\n ) {\n const path = fileURLToPath(url);\n const source = readFileSync(path, 'utf8');\n\n const transformed = transformSync(source, {\n cwd: dirname(path),\n envName,\n filename: basename(path),\n root,\n });\n\n const res: LoadFnOutput = {\n format: 'module',\n shortCircuit: true,\n source: transformed?.code ?? '',\n };\n\n cache.set(url, res);\n return res;\n }\n\n return next(url, context);\n },\n });\n}\n\nconst CANDIDATE_EXTENSIONS = [\n '.js',\n '.jsx',\n '.ts',\n '.tsx',\n];\n\nfunction resolveExtension(base: string): null | string {\n for (const ext of CANDIDATE_EXTENSIONS) {\n const path = base + ext;\n if (existsSync(path)) return path;\n }\n\n return null;\n}\n\n/**\n * Registers a Node module API hook that customizes ES module resolution\n * to make mandatory file extensions optional.\n */\nexport function registerResolver(): void {\n registerHooks({\n resolve(specifier, context, next) {\n let path = specifier;\n\n const isAbsolute = path.startsWith('/');\n const isRelative = path.startsWith('.');\n\n if (isAbsolute || isRelative) {\n if (isRelative) path = new URL(path, context.parentURL).pathname;\n const stat = statSync(path, { throwIfNoEntry: false });\n if (!stat?.isFile()) {\n path = resolveExtension(path)\n ?? (stat?.isDirectory() ? resolveExtension(`${path}/index`) : null)\n ?? specifier;\n }\n }\n\n return next(path, context);\n },\n });\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA,OAAS,UAAU,CAAE,YAAY,CAAE,QAAQ,KAAQ,SAAS,CAC5D,OAA4B,aAAa,CAAE,aAAa,KAAQ,aAAa,CAC7E,OAAS,QAAQ,CAAE,OAAO,KAAQ,WAAW,CAC7C,OAAS,aAAa,KAAQ,UAAU,CAIxC,KAAM,QAAO,CAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAO9C;AACA;AACA;AACA;AACA;AACA;AACA,GACA,MAAO,SAAS,oBAAmB,CAAC,CAClC,OAAO,CAAG,aAAa,CACvB,IAAI,CAAG,OAAO,CAAC,GAAG,CAAC,CACI,CAAC,CAAG,CAAC,CAAC,CAAQ,CACrC;AACA,KAAM,CAAE,aAAc,CAAC,CAAG,OAAO,CAAC,aAAa,CAAqB,CAEpE,KAAM,MAAK,CAAG,GAAI,IAA2B,CAE7C,aAAa,CAAC,CACZ,IAAI,CAAC,GAAG,CAAE,OAAO,CAAE,IAAI,CAAE,CACvB,KAAM,OAAM,CAA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S,CAAE,OAAO,CAAE,IAAI,CAAE,CAChC,GAAI,KAAI,CAAG,SAAS,CAEpB,KAAM,WAAU,CAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CACvC,KAAM,WAAU,CAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAEvC,GAAI,UAAU,EAAI,UAAU,CAAE,CAC5B,GAAI,UAAU,CAAE,IAAI,CAAG,GAAI,IAAG,CAAC,IAAI,CAAE,OAAO,CAAC,SAAS,CAAC,CAAC,QAAQ,CAChE,KAAM,KAAI,CAAG,QAAQ,CAAC,IAAI,CAAE,CAAE,cAAc,CAAE,KAAM,CAAC,CAAC,CACtD,GAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAE,CACnB,IAAI,CAAG,gBAAgB,CAAC,IAAI,CAAC,GACvB,IAAI,EAAE,WAAW,CAAC,CAAC,CAAG,gBAAgB,CAAC,GAAG,IAAI,QAAQ,CAAC,CAAG,IAAI,CAAC,EAChE,SAAS,CAChB,CACF,CAEA,MAAO,KAAI,CAAC,IAAI,CAAE,OAAO,CAAC,CAC5B,CACF,CAAC,CAAC,CACJ","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.56.
|
|
2
|
+
"version": "1.56.2",
|
|
3
3
|
"bin": {
|
|
4
4
|
"react-utils-build": "bin/build.js",
|
|
5
5
|
"react-utils-run-with-babel": "bin/run-with-babel.js",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"@types/morgan": "^1.9.10",
|
|
76
76
|
"@types/pretty": "^2.0.3",
|
|
77
77
|
"@types/react": "^19.2.18",
|
|
78
|
-
"@types/react-dom": "^19.2.
|
|
78
|
+
"@types/react-dom": "^19.2.5",
|
|
79
79
|
"@types/request-ip": "^0.0.41",
|
|
80
80
|
"@types/serialize-javascript": "^5.0.4",
|
|
81
81
|
"@types/serve-favicon": "^2.5.7",
|