@dr.pogodin/react-utils 1.56.1 → 1.56.3
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 +16 -18
- package/patches/jest-resolve+30.4.1.patch +0 -29
|
@@ -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?.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,SAAS,UAAU,EAAE,YAAY,EAAE,QAAQ,QAAQ,SAAS;AAC5D,SAA4B,aAAa,EAAE,aAAa,QAAQ,aAAa;AAC7E,SAAS,QAAQ,EAAE,OAAO,QAAQ,WAAW;AAC7C,SAAS,aAAa,QAAQ,UAAU;AAIxC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAO9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAAS,mBAAmB,CAAC;EAClC,OAAO,GAAG,aAAa;EACvB,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC;AACI,CAAC,GAAG,CAAC,CAAC,EAAQ;EACrC;EACA,MAAM;IAAE;EAAc,CAAC,GAAG,OAAO,CAAC,aAAa,CAAqB;EAEpE,MAAM,KAAK,GAAG,IAAI,GAA2B,CAA3B,CAA2B;EAE7C,aAAa,CAAC;IACZ,IAAI,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE;MACvB,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC;MAC7B,IAAI,MAAM,KAAK,SAAS,EAAE,OAAO,MAAM;MAEvC,IACE,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,IACtB,CAAC,GAAG,CAAC,QAAQ,CAAC,gBAAgB,CAAC,IAC/B,CAAC,GAAG,CAAC,QAAQ,CAAC,gBAAgB,CAAC,IAC/B,GAAG,CAAC,KAAK,CAAC,uBAAuB,CAAC,EACrC;QACA,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,CAAC;QAC/B,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC;QAEzC,MAAM,WAAW,GAAG,aAAa,CAAC,MAAM,EAAE;UACx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CAAC,EAAE;UACnB,IAAI,GAAG,gBAAgB,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,CAA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AAU,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":[]}
|
|
@@ -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,I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AAa,CAAC,CACZ,OAAO,CAAC,SAAS,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.3",
|
|
3
3
|
"bin": {
|
|
4
4
|
"react-utils-build": "bin/build.js",
|
|
5
5
|
"react-utils-run-with-babel": "bin/run-with-babel.js",
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
"@dr.pogodin/react-global-state": "^0.25.0",
|
|
18
18
|
"@dr.pogodin/react-helmet": "^3.2.3",
|
|
19
19
|
"@dr.pogodin/react-themes": "^1.11.0",
|
|
20
|
-
"@jest/environment": "^30.
|
|
21
|
-
"axios": "^1.
|
|
20
|
+
"@jest/environment": "^30.5.0",
|
|
21
|
+
"axios": "^1.20.0",
|
|
22
22
|
"commander": "^15.0.0",
|
|
23
23
|
"compression": "^1.8.1",
|
|
24
|
-
"config": "^
|
|
24
|
+
"config": "^5.0.1",
|
|
25
25
|
"cookie": "^2.0.1",
|
|
26
26
|
"cookie-parser": "^1.4.7",
|
|
27
27
|
"core-js-pure": "^3.50.0",
|
|
@@ -31,12 +31,12 @@
|
|
|
31
31
|
"helmet": "^8.3.0",
|
|
32
32
|
"http-status-codes": "^2.3.0",
|
|
33
33
|
"lodash-es": "^4.18.1",
|
|
34
|
-
"morgan": "^1.
|
|
34
|
+
"morgan": "^1.12.0",
|
|
35
35
|
"qs": "^6.15.3",
|
|
36
36
|
"raf": "^3.4.1",
|
|
37
37
|
"react": "^19.2.8",
|
|
38
38
|
"react-dom": "^19.2.8",
|
|
39
|
-
"react-router": "^8.3.
|
|
39
|
+
"react-router": "^8.3.1",
|
|
40
40
|
"request-ip": "^3.3.0",
|
|
41
41
|
"rimraf": "^6.1.3",
|
|
42
42
|
"serialize-javascript": "^7.1.0",
|
|
@@ -57,11 +57,11 @@
|
|
|
57
57
|
"@dr.pogodin/babel-plugin-transform-assets": "^2.0.0",
|
|
58
58
|
"@dr.pogodin/babel-preset-svgr": "^2.0.0",
|
|
59
59
|
"@dr.pogodin/eslint-configs": "^0.3.6",
|
|
60
|
-
"@jest/globals": "^30.
|
|
61
|
-
"@pmmmwh/react-refresh-webpack-plugin": "^0.6.
|
|
60
|
+
"@jest/globals": "^30.5.0",
|
|
61
|
+
"@pmmmwh/react-refresh-webpack-plugin": "^0.6.3",
|
|
62
62
|
"@standard-schema/spec": "^1.1.0",
|
|
63
63
|
"@testing-library/dom": "^10.4.1",
|
|
64
|
-
"@testing-library/react": "^16.3.
|
|
64
|
+
"@testing-library/react": "^16.3.3",
|
|
65
65
|
"@testing-library/user-event": "^14.6.6",
|
|
66
66
|
"@tsconfig/recommended": "^1.0.13",
|
|
67
67
|
"@types/compression": "^1.8.1",
|
|
@@ -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",
|
|
@@ -83,21 +83,20 @@
|
|
|
83
83
|
"@types/webpack": "^5.28.5",
|
|
84
84
|
"@types/webpack-hot-middleware": "^2.25.12",
|
|
85
85
|
"autoprefixer": "^10.5.4",
|
|
86
|
-
"babel-jest": "^30.
|
|
86
|
+
"babel-jest": "^30.5.0",
|
|
87
87
|
"babel-loader": "^10.1.1",
|
|
88
88
|
"babel-plugin-module-resolver": "^5.0.3",
|
|
89
89
|
"babel-plugin-polyfill-corejs3": "^1.0.0",
|
|
90
90
|
"babel-plugin-react-compiler": "^1.0.0",
|
|
91
|
-
"css-loader": "^7.1.
|
|
91
|
+
"css-loader": "^7.1.5",
|
|
92
92
|
"css-minimizer-webpack-plugin": "^8.0.0",
|
|
93
93
|
"identity-obj-proxy": "^3.0.0",
|
|
94
|
-
"jest": "^30.
|
|
95
|
-
"jest-environment-jsdom": "^30.
|
|
96
|
-
"memfs": "^4.68.
|
|
94
|
+
"jest": "^30.5.0",
|
|
95
|
+
"jest-environment-jsdom": "^30.5.0",
|
|
96
|
+
"memfs": "^4.68.2",
|
|
97
97
|
"mini-css-extract-plugin": "^2.10.2",
|
|
98
98
|
"mockdate": "^3.0.5",
|
|
99
99
|
"nodelist-foreach-polyfill": "^1.2.0",
|
|
100
|
-
"patch-package": "^8.0.1",
|
|
101
100
|
"postcss": "^8.5.26",
|
|
102
101
|
"postcss-loader": "^8.2.1",
|
|
103
102
|
"postcss-scss": "^4.0.9",
|
|
@@ -115,7 +114,7 @@
|
|
|
115
114
|
"tstyche": "^7.2.3",
|
|
116
115
|
"typed-scss-modules": "^8.1.1",
|
|
117
116
|
"typescript": "^6.0.3",
|
|
118
|
-
"webpack": "^5.
|
|
117
|
+
"webpack": "^5.110.1",
|
|
119
118
|
"webpack-dev-middleware": "^8.1.1",
|
|
120
119
|
"webpack-hot-middleware": "^2.26.1",
|
|
121
120
|
"webpack-merge": "^6.0.1",
|
|
@@ -191,7 +190,6 @@
|
|
|
191
190
|
"lint": "npm run lint:code && npm run lint:scss",
|
|
192
191
|
"lint:code": "eslint --cache --cache-strategy content",
|
|
193
192
|
"lint:scss": "stylelint -- **/*.{css,scss}",
|
|
194
|
-
"postinstall": "patch-package || true",
|
|
195
193
|
"test": "npm run lint && npm run typecheck && npm run jest",
|
|
196
194
|
"typecheck": "tsc --noEmit"
|
|
197
195
|
},
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
diff --git a/node_modules/jest-resolve/build/index.js b/node_modules/jest-resolve/build/index.js
|
|
2
|
-
index 2dbd326..f480209 100644
|
|
3
|
-
--- a/node_modules/jest-resolve/build/index.js
|
|
4
|
-
+++ b/node_modules/jest-resolve/build/index.js
|
|
5
|
-
@@ -1165,7 +1165,7 @@ function loadResolver(resolver) {
|
|
6
|
-
if (resolver == null) {
|
|
7
|
-
return _defaultResolver.default;
|
|
8
|
-
}
|
|
9
|
-
- const loadedResolver = require(resolver);
|
|
10
|
-
+ let loadedResolver = require(resolver);
|
|
11
|
-
if (loadedResolver == null) {
|
|
12
|
-
throw new Error(`Resolver located at ${resolver} does not export anything`);
|
|
13
|
-
}
|
|
14
|
-
@@ -1175,6 +1175,15 @@ function loadResolver(resolver) {
|
|
15
|
-
if (typeof loadedResolver === 'object' && (loadedResolver.sync != null || loadedResolver.async != null)) {
|
|
16
|
-
return loadedResolver;
|
|
17
|
-
}
|
|
18
|
-
+ if (typeof loadedResolver === 'object' && loadedResolver.default) {
|
|
19
|
-
+ loadedResolver = loadedResolver.default;
|
|
20
|
-
+ if (typeof loadedResolver === 'function') {
|
|
21
|
-
+ return loadedResolver;
|
|
22
|
-
+ }
|
|
23
|
-
+ if (typeof loadedResolver === 'object' && (loadedResolver.sync != null || loadedResolver.async != null)) {
|
|
24
|
-
+ return loadedResolver;
|
|
25
|
-
+ }
|
|
26
|
-
+ }
|
|
27
|
-
throw new Error(`Resolver located at ${resolver} does not export a function or an object with "sync" and "async" props`);
|
|
28
|
-
}
|
|
29
|
-
|