@mokup/shared 1.1.0 → 1.1.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.
Files changed (71) hide show
  1. package/dist/config-core.cjs +9 -0
  2. package/dist/config-core.d.cts +4 -0
  3. package/dist/config-core.d.mts +4 -0
  4. package/dist/config-core.d.ts +4 -0
  5. package/dist/config-core.mjs +6 -0
  6. package/dist/config-utils.cjs +179 -0
  7. package/dist/config-utils.d.cts +62 -0
  8. package/dist/config-utils.d.mts +62 -0
  9. package/dist/config-utils.d.ts +62 -0
  10. package/dist/config-utils.mjs +171 -0
  11. package/dist/define-config.cjs +168 -0
  12. package/dist/define-config.d.cts +20 -0
  13. package/dist/define-config.d.mts +20 -0
  14. package/dist/define-config.d.ts +20 -0
  15. package/dist/define-config.mjs +166 -0
  16. package/dist/index.cjs +48 -0
  17. package/dist/index.d.cts +10 -98
  18. package/dist/index.d.mts +10 -98
  19. package/dist/index.d.ts +10 -98
  20. package/dist/index.mjs +18 -1
  21. package/dist/jsonc-utils.cjs +25 -0
  22. package/dist/jsonc-utils.d.cts +7 -0
  23. package/dist/jsonc-utils.d.mts +7 -0
  24. package/dist/jsonc-utils.d.ts +7 -0
  25. package/dist/jsonc-utils.mjs +23 -0
  26. package/dist/load-rules.cjs +39 -0
  27. package/dist/load-rules.d.cts +14 -0
  28. package/dist/load-rules.d.mts +14 -0
  29. package/dist/load-rules.d.ts +14 -0
  30. package/dist/load-rules.mjs +37 -0
  31. package/dist/mock-files.cjs +65 -0
  32. package/dist/mock-files.d.cts +10 -0
  33. package/dist/mock-files.d.mts +10 -0
  34. package/dist/mock-files.d.ts +10 -0
  35. package/dist/mock-files.mjs +61 -0
  36. package/dist/module-loader.cjs +93 -0
  37. package/dist/module-loader.d.cts +13 -0
  38. package/dist/module-loader.d.mts +13 -0
  39. package/dist/module-loader.d.ts +13 -0
  40. package/dist/module-loader.mjs +83 -0
  41. package/dist/path-utils.cjs +57 -0
  42. package/dist/path-utils.d.cts +7 -0
  43. package/dist/path-utils.d.mts +7 -0
  44. package/dist/path-utils.d.ts +7 -0
  45. package/dist/path-utils.mjs +51 -0
  46. package/dist/playground-grouping.cjs +95 -0
  47. package/dist/playground-grouping.d.cts +12 -0
  48. package/dist/playground-grouping.d.mts +12 -0
  49. package/dist/playground-grouping.d.ts +12 -0
  50. package/dist/playground-grouping.mjs +90 -0
  51. package/dist/route-constants.cjs +30 -0
  52. package/dist/route-constants.d.cts +7 -0
  53. package/dist/route-constants.d.mts +7 -0
  54. package/dist/route-constants.d.ts +7 -0
  55. package/dist/route-constants.mjs +24 -0
  56. package/dist/route-utils.cjs +126 -0
  57. package/dist/route-utils.d.cts +42 -0
  58. package/dist/route-utils.d.mts +42 -0
  59. package/dist/route-utils.d.ts +42 -0
  60. package/dist/route-utils.mjs +124 -0
  61. package/dist/scan-utils.cjs +39 -0
  62. package/dist/scan-utils.d.cts +114 -0
  63. package/dist/scan-utils.d.mts +114 -0
  64. package/dist/scan-utils.d.ts +114 -0
  65. package/dist/scan-utils.mjs +34 -0
  66. package/dist/timing.cjs +20 -0
  67. package/dist/timing.d.cts +4 -0
  68. package/dist/timing.d.mts +4 -0
  69. package/dist/timing.d.ts +4 -0
  70. package/dist/timing.mjs +17 -0
  71. package/package.json +81 -18
package/dist/index.d.ts CHANGED
@@ -1,98 +1,10 @@
1
- /**
2
- * Directory input for mock scanning.
3
- *
4
- * @example
5
- * import type { DirInput } from '@mokup/shared'
6
- *
7
- * const dir: DirInput = ['mock', 'fixtures']
8
- */
9
- type DirInput = string | string[] | ((root: string) => string | string[]) | undefined;
10
- /**
11
- * Shared entry options for mokup scanners and plugins.
12
- *
13
- * @example
14
- * import type { MockEntryOptions } from '@mokup/shared'
15
- *
16
- * const entry: MockEntryOptions = {
17
- * dir: 'mock',
18
- * prefix: '/api',
19
- * watch: true,
20
- * }
21
- */
22
- interface MockEntryOptions {
23
- /**
24
- * Directory (or directories) to scan for mock routes.
25
- *
26
- * @default "mock" (resolved by Vite/webpack plugins)
27
- */
28
- dir?: DirInput;
29
- /**
30
- * Request path prefix to mount mock routes under.
31
- *
32
- * @default ""
33
- */
34
- prefix?: string;
35
- /**
36
- * Include filter for files to scan.
37
- *
38
- * @default undefined
39
- */
40
- include?: RegExp | RegExp[];
41
- /**
42
- * Exclude filter for files to scan.
43
- *
44
- * @default undefined
45
- */
46
- exclude?: RegExp | RegExp[];
47
- /**
48
- * Ignore file or folder prefixes when scanning.
49
- *
50
- * @default ["."]
51
- */
52
- ignorePrefix?: string | string[];
53
- /**
54
- * Enable file watching for live route updates.
55
- *
56
- * @default true
57
- */
58
- watch?: boolean;
59
- /**
60
- * Enable mokup logging.
61
- *
62
- * @default true
63
- */
64
- log?: boolean;
65
- }
66
- /**
67
- * Playground configuration input.
68
- *
69
- * @example
70
- * import type { PlaygroundOptionsInput } from '@mokup/shared'
71
- *
72
- * const playground: PlaygroundOptionsInput = {
73
- * path: '/__mokup',
74
- * enabled: true,
75
- * }
76
- */
77
- type PlaygroundOptionsInput = boolean | {
78
- /**
79
- * Base path for the playground UI.
80
- *
81
- * @default "/__mokup"
82
- */
83
- path?: string;
84
- /**
85
- * Emit playground assets during production builds.
86
- *
87
- * @default false
88
- */
89
- build?: boolean;
90
- /**
91
- * Enable or disable the playground routes.
92
- *
93
- * @default true
94
- */
95
- enabled?: boolean;
96
- } | undefined;
97
-
98
- export type { DirInput, MockEntryOptions, PlaygroundOptionsInput };
1
+ export { isPromise, middlewareSymbol } from './config-core.js';
2
+ export { ConfigSourceMap, MiddlewareMeta, MiddlewarePosition, buildConfigChain, findConfigFile, getConfigFileCandidates, normalizeMiddlewareList, readMiddlewareMeta, resolveDirectoryConfig } from './config-utils.js';
3
+ export { ConfigApp, DefineConfigFactory, HookErrorPolicy, HookHandler, createDefineConfig } from './define-config.js';
4
+ export { readJsoncFile } from './jsonc-utils.js';
5
+ export { loadRules } from './load-rules.js';
6
+ export { collectFiles, isConfigFile, isSupportedFile } from './mock-files.js';
7
+ export { createTsxConfigFile, ensureTsxRegister, loadModule } from './module-loader.js';
8
+ export { configExtensions, jsonExtensions, methodSet, methodSuffixSet, supportedExtensions } from './route-constants.js';
9
+ export { DerivedRoute, RouteParser, RouteParserResult, RouteScoreComparator, createRouteUtils } from './route-utils.js';
10
+ export { D as DirInput, M as MockEntryOptions, P as PlaygroundOptionsInput, normalizeIgnorePrefix, normalizeMethod, normalizePrefix, resolveDirs } from './scan-utils.js';
package/dist/index.mjs CHANGED
@@ -1 +1,18 @@
1
-
1
+ export { isPromise, middlewareSymbol } from './config-core.mjs';
2
+ export { buildConfigChain, findConfigFile, getConfigFileCandidates, normalizeMiddlewareList, readMiddlewareMeta, resolveDirectoryConfig } from './config-utils.mjs';
3
+ export { createDefineConfig } from './define-config.mjs';
4
+ export { readJsoncFile } from './jsonc-utils.mjs';
5
+ export { loadRules } from './load-rules.mjs';
6
+ export { collectFiles, isConfigFile, isSupportedFile } from './mock-files.mjs';
7
+ export { createTsxConfigFile, ensureTsxRegister, loadModule } from './module-loader.mjs';
8
+ export { configExtensions, jsonExtensions, methodSet, methodSuffixSet, supportedExtensions } from './route-constants.mjs';
9
+ export { createRouteUtils } from './route-utils.mjs';
10
+ export { normalizeIgnorePrefix, normalizeMethod, normalizePrefix, resolveDirs } from './scan-utils.mjs';
11
+ import 'node:fs';
12
+ import 'pathe';
13
+ import 'jsonc-parser';
14
+ import 'node:module';
15
+ import 'node:os';
16
+ import 'node:process';
17
+ import 'node:url';
18
+ import './path-utils.mjs';
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ const node_fs = require('node:fs');
4
+ const jsoncParser = require('jsonc-parser');
5
+
6
+ async function readJsoncFile(file, logger) {
7
+ try {
8
+ const content = await node_fs.promises.readFile(file, "utf8");
9
+ const errors = [];
10
+ const data = jsoncParser.parse(content, errors, {
11
+ allowTrailingComma: true,
12
+ disallowComments: false
13
+ });
14
+ if (errors.length > 0) {
15
+ logger?.warn?.(`Invalid JSONC in ${file}`);
16
+ return void 0;
17
+ }
18
+ return data;
19
+ } catch (error) {
20
+ logger?.warn?.(`Failed to read ${file}: ${String(error)}`);
21
+ return void 0;
22
+ }
23
+ }
24
+
25
+ exports.readJsoncFile = readJsoncFile;
@@ -0,0 +1,7 @@
1
+ interface JsoncLogger {
2
+ warn?: (message: string) => void;
3
+ }
4
+ declare function readJsoncFile(file: string, logger?: JsoncLogger): Promise<any>;
5
+
6
+ export { readJsoncFile };
7
+ export type { JsoncLogger };
@@ -0,0 +1,7 @@
1
+ interface JsoncLogger {
2
+ warn?: (message: string) => void;
3
+ }
4
+ declare function readJsoncFile(file: string, logger?: JsoncLogger): Promise<any>;
5
+
6
+ export { readJsoncFile };
7
+ export type { JsoncLogger };
@@ -0,0 +1,7 @@
1
+ interface JsoncLogger {
2
+ warn?: (message: string) => void;
3
+ }
4
+ declare function readJsoncFile(file: string, logger?: JsoncLogger): Promise<any>;
5
+
6
+ export { readJsoncFile };
7
+ export type { JsoncLogger };
@@ -0,0 +1,23 @@
1
+ import { promises } from 'node:fs';
2
+ import { parse } from 'jsonc-parser';
3
+
4
+ async function readJsoncFile(file, logger) {
5
+ try {
6
+ const content = await promises.readFile(file, "utf8");
7
+ const errors = [];
8
+ const data = parse(content, errors, {
9
+ allowTrailingComma: true,
10
+ disallowComments: false
11
+ });
12
+ if (errors.length > 0) {
13
+ logger?.warn?.(`Invalid JSONC in ${file}`);
14
+ return void 0;
15
+ }
16
+ return data;
17
+ } catch (error) {
18
+ logger?.warn?.(`Failed to read ${file}: ${String(error)}`);
19
+ return void 0;
20
+ }
21
+ }
22
+
23
+ export { readJsoncFile };
@@ -0,0 +1,39 @@
1
+ 'use strict';
2
+
3
+ const jsoncUtils = require('./jsonc-utils.cjs');
4
+ const pathe = require('pathe');
5
+ require('node:fs');
6
+ require('jsonc-parser');
7
+
8
+ async function loadRules(file, options) {
9
+ const ext = pathe.extname(file).toLowerCase();
10
+ if (ext === ".json" || ext === ".jsonc") {
11
+ const json = await jsoncUtils.readJsoncFile(file, options.logger);
12
+ if (typeof json === "undefined") {
13
+ return [];
14
+ }
15
+ return [
16
+ {
17
+ handler: json
18
+ }
19
+ ];
20
+ }
21
+ const mod = await options.loadModule(file);
22
+ const value = mod?.default ?? mod;
23
+ if (!value) {
24
+ return [];
25
+ }
26
+ if (Array.isArray(value)) {
27
+ return value;
28
+ }
29
+ if (typeof value === "function") {
30
+ return [
31
+ {
32
+ handler: value
33
+ }
34
+ ];
35
+ }
36
+ return [value];
37
+ }
38
+
39
+ exports.loadRules = loadRules;
@@ -0,0 +1,14 @@
1
+ interface LoadRulesOptions {
2
+ loadModule: (file: string) => Promise<unknown | null>;
3
+ logger?: {
4
+ warn?: (message: string) => void;
5
+ };
6
+ }
7
+ declare function loadRules<T extends {
8
+ handler: unknown;
9
+ } = {
10
+ handler: unknown;
11
+ }>(file: string, options: LoadRulesOptions): Promise<T[]>;
12
+
13
+ export { loadRules };
14
+ export type { LoadRulesOptions };
@@ -0,0 +1,14 @@
1
+ interface LoadRulesOptions {
2
+ loadModule: (file: string) => Promise<unknown | null>;
3
+ logger?: {
4
+ warn?: (message: string) => void;
5
+ };
6
+ }
7
+ declare function loadRules<T extends {
8
+ handler: unknown;
9
+ } = {
10
+ handler: unknown;
11
+ }>(file: string, options: LoadRulesOptions): Promise<T[]>;
12
+
13
+ export { loadRules };
14
+ export type { LoadRulesOptions };
@@ -0,0 +1,14 @@
1
+ interface LoadRulesOptions {
2
+ loadModule: (file: string) => Promise<unknown | null>;
3
+ logger?: {
4
+ warn?: (message: string) => void;
5
+ };
6
+ }
7
+ declare function loadRules<T extends {
8
+ handler: unknown;
9
+ } = {
10
+ handler: unknown;
11
+ }>(file: string, options: LoadRulesOptions): Promise<T[]>;
12
+
13
+ export { loadRules };
14
+ export type { LoadRulesOptions };
@@ -0,0 +1,37 @@
1
+ import { readJsoncFile } from './jsonc-utils.mjs';
2
+ import { extname } from 'pathe';
3
+ import 'node:fs';
4
+ import 'jsonc-parser';
5
+
6
+ async function loadRules(file, options) {
7
+ const ext = extname(file).toLowerCase();
8
+ if (ext === ".json" || ext === ".jsonc") {
9
+ const json = await readJsoncFile(file, options.logger);
10
+ if (typeof json === "undefined") {
11
+ return [];
12
+ }
13
+ return [
14
+ {
15
+ handler: json
16
+ }
17
+ ];
18
+ }
19
+ const mod = await options.loadModule(file);
20
+ const value = mod?.default ?? mod;
21
+ if (!value) {
22
+ return [];
23
+ }
24
+ if (Array.isArray(value)) {
25
+ return value;
26
+ }
27
+ if (typeof value === "function") {
28
+ return [
29
+ {
30
+ handler: value
31
+ }
32
+ ];
33
+ }
34
+ return [value];
35
+ }
36
+
37
+ export { loadRules };
@@ -0,0 +1,65 @@
1
+ 'use strict';
2
+
3
+ const node_fs = require('node:fs');
4
+ const pathe = require('pathe');
5
+ const routeConstants = require('./route-constants.cjs');
6
+
7
+ async function walkDir(dir, rootDir, files) {
8
+ const entries = await node_fs.promises.readdir(dir, { withFileTypes: true });
9
+ for (const entry of entries) {
10
+ if (entry.name === "node_modules" || entry.name === ".git") {
11
+ continue;
12
+ }
13
+ const fullPath = pathe.join(dir, entry.name);
14
+ if (entry.isDirectory()) {
15
+ await walkDir(fullPath, rootDir, files);
16
+ continue;
17
+ }
18
+ if (entry.isFile()) {
19
+ files.push({ file: fullPath, rootDir });
20
+ }
21
+ }
22
+ }
23
+ async function exists(path) {
24
+ try {
25
+ await node_fs.promises.stat(path);
26
+ return true;
27
+ } catch {
28
+ return false;
29
+ }
30
+ }
31
+ async function collectFiles(dirs) {
32
+ const files = [];
33
+ for (const dir of dirs) {
34
+ if (!await exists(dir)) {
35
+ continue;
36
+ }
37
+ await walkDir(dir, dir, files);
38
+ }
39
+ return files;
40
+ }
41
+ function isConfigFile(file) {
42
+ if (file.endsWith(".d.ts")) {
43
+ return false;
44
+ }
45
+ const base = pathe.basename(file);
46
+ if (!base.startsWith("index.config.")) {
47
+ return false;
48
+ }
49
+ const ext = pathe.extname(file).toLowerCase();
50
+ return routeConstants.configExtensions.includes(ext);
51
+ }
52
+ function isSupportedFile(file) {
53
+ if (file.endsWith(".d.ts")) {
54
+ return false;
55
+ }
56
+ if (isConfigFile(file)) {
57
+ return false;
58
+ }
59
+ const ext = pathe.extname(file).toLowerCase();
60
+ return routeConstants.supportedExtensions.has(ext);
61
+ }
62
+
63
+ exports.collectFiles = collectFiles;
64
+ exports.isConfigFile = isConfigFile;
65
+ exports.isSupportedFile = isSupportedFile;
@@ -0,0 +1,10 @@
1
+ interface FileInfo {
2
+ file: string;
3
+ rootDir: string;
4
+ }
5
+ declare function collectFiles(dirs: string[]): Promise<FileInfo[]>;
6
+ declare function isConfigFile(file: string): boolean;
7
+ declare function isSupportedFile(file: string): boolean;
8
+
9
+ export { collectFiles, isConfigFile, isSupportedFile };
10
+ export type { FileInfo };
@@ -0,0 +1,10 @@
1
+ interface FileInfo {
2
+ file: string;
3
+ rootDir: string;
4
+ }
5
+ declare function collectFiles(dirs: string[]): Promise<FileInfo[]>;
6
+ declare function isConfigFile(file: string): boolean;
7
+ declare function isSupportedFile(file: string): boolean;
8
+
9
+ export { collectFiles, isConfigFile, isSupportedFile };
10
+ export type { FileInfo };
@@ -0,0 +1,10 @@
1
+ interface FileInfo {
2
+ file: string;
3
+ rootDir: string;
4
+ }
5
+ declare function collectFiles(dirs: string[]): Promise<FileInfo[]>;
6
+ declare function isConfigFile(file: string): boolean;
7
+ declare function isSupportedFile(file: string): boolean;
8
+
9
+ export { collectFiles, isConfigFile, isSupportedFile };
10
+ export type { FileInfo };
@@ -0,0 +1,61 @@
1
+ import { promises } from 'node:fs';
2
+ import { basename, extname, join } from 'pathe';
3
+ import { configExtensions, supportedExtensions } from './route-constants.mjs';
4
+
5
+ async function walkDir(dir, rootDir, files) {
6
+ const entries = await promises.readdir(dir, { withFileTypes: true });
7
+ for (const entry of entries) {
8
+ if (entry.name === "node_modules" || entry.name === ".git") {
9
+ continue;
10
+ }
11
+ const fullPath = join(dir, entry.name);
12
+ if (entry.isDirectory()) {
13
+ await walkDir(fullPath, rootDir, files);
14
+ continue;
15
+ }
16
+ if (entry.isFile()) {
17
+ files.push({ file: fullPath, rootDir });
18
+ }
19
+ }
20
+ }
21
+ async function exists(path) {
22
+ try {
23
+ await promises.stat(path);
24
+ return true;
25
+ } catch {
26
+ return false;
27
+ }
28
+ }
29
+ async function collectFiles(dirs) {
30
+ const files = [];
31
+ for (const dir of dirs) {
32
+ if (!await exists(dir)) {
33
+ continue;
34
+ }
35
+ await walkDir(dir, dir, files);
36
+ }
37
+ return files;
38
+ }
39
+ function isConfigFile(file) {
40
+ if (file.endsWith(".d.ts")) {
41
+ return false;
42
+ }
43
+ const base = basename(file);
44
+ if (!base.startsWith("index.config.")) {
45
+ return false;
46
+ }
47
+ const ext = extname(file).toLowerCase();
48
+ return configExtensions.includes(ext);
49
+ }
50
+ function isSupportedFile(file) {
51
+ if (file.endsWith(".d.ts")) {
52
+ return false;
53
+ }
54
+ if (isConfigFile(file)) {
55
+ return false;
56
+ }
57
+ const ext = extname(file).toLowerCase();
58
+ return supportedExtensions.has(ext);
59
+ }
60
+
61
+ export { collectFiles, isConfigFile, isSupportedFile };
@@ -0,0 +1,93 @@
1
+ 'use strict';
2
+
3
+ const node_fs = require('node:fs');
4
+ const node_module = require('node:module');
5
+ const node_os = require('node:os');
6
+ const process = require('node:process');
7
+ const node_url = require('node:url');
8
+ const pathe = require('pathe');
9
+
10
+ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
11
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
12
+
13
+ const process__default = /*#__PURE__*/_interopDefaultCompat(process);
14
+
15
+ function createTsxConfigFile(options) {
16
+ const config = {
17
+ compilerOptions: {
18
+ baseUrl: options.baseUrl,
19
+ paths: options.paths
20
+ }
21
+ };
22
+ const configPath = options.fileName ?? pathe.resolve(node_os.tmpdir(), `mokup-tsx-${process__default.pid}.json`);
23
+ node_fs.writeFileSync(configPath, `${JSON.stringify(config, null, 2)}
24
+ `, "utf8");
25
+ return configPath;
26
+ }
27
+ let sourceMapsEnabled = false;
28
+ let tsxRegisterPromise = null;
29
+ let tsxRegisteredConfig = null;
30
+ function resetModuleLoaderForTests() {
31
+ sourceMapsEnabled = false;
32
+ tsxRegisterPromise = null;
33
+ tsxRegisteredConfig = null;
34
+ }
35
+ function ensureSourceMapsEnabled() {
36
+ if (sourceMapsEnabled) {
37
+ return;
38
+ }
39
+ const setSourceMapsEnabled = process__default.setSourceMapsEnabled;
40
+ if (typeof setSourceMapsEnabled === "function") {
41
+ setSourceMapsEnabled(true);
42
+ }
43
+ sourceMapsEnabled = true;
44
+ }
45
+ async function ensureTsxRegister(tsconfigPath) {
46
+ const desired = tsconfigPath ?? null;
47
+ if (tsxRegisterPromise) {
48
+ await tsxRegisterPromise;
49
+ if (desired && tsxRegisteredConfig !== desired) {
50
+ tsxRegisterPromise = (async () => {
51
+ ensureSourceMapsEnabled();
52
+ const { register } = await import('tsx/esm/api');
53
+ register({ tsconfig: desired });
54
+ tsxRegisteredConfig = desired;
55
+ })();
56
+ await tsxRegisterPromise;
57
+ }
58
+ return tsxRegisterPromise;
59
+ }
60
+ tsxRegisterPromise = (async () => {
61
+ ensureSourceMapsEnabled();
62
+ const { register } = await import('tsx/esm/api');
63
+ if (desired) {
64
+ register({ tsconfig: desired });
65
+ tsxRegisteredConfig = desired;
66
+ } else {
67
+ register();
68
+ tsxRegisteredConfig = null;
69
+ }
70
+ })();
71
+ return tsxRegisterPromise;
72
+ }
73
+ async function loadModule(file, options) {
74
+ const ext = pathe.extname(file).toLowerCase();
75
+ if (ext === ".cjs") {
76
+ const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('module-loader.cjs', document.baseURI).href)));
77
+ delete require$1.cache[file];
78
+ return require$1(file);
79
+ }
80
+ if (ext === ".js" || ext === ".mjs") {
81
+ return import(`${node_url.pathToFileURL(file).href}?t=${Date.now()}`);
82
+ }
83
+ if (ext === ".ts") {
84
+ await ensureTsxRegister(options?.tsconfigPath ?? null);
85
+ return import(`${node_url.pathToFileURL(file).href}?t=${Date.now()}`);
86
+ }
87
+ return null;
88
+ }
89
+
90
+ exports.createTsxConfigFile = createTsxConfigFile;
91
+ exports.ensureTsxRegister = ensureTsxRegister;
92
+ exports.loadModule = loadModule;
93
+ exports.resetModuleLoaderForTests = resetModuleLoaderForTests;
@@ -0,0 +1,13 @@
1
+ interface TsxConfigOptions {
2
+ baseUrl: string;
3
+ paths: Record<string, string[]>;
4
+ fileName?: string;
5
+ }
6
+ declare function createTsxConfigFile(options: TsxConfigOptions): string;
7
+ declare function resetModuleLoaderForTests(): void;
8
+ declare function ensureTsxRegister(tsconfigPath?: string | null): Promise<void>;
9
+ declare function loadModule(file: string, options?: {
10
+ tsconfigPath?: string | null;
11
+ }): Promise<any>;
12
+
13
+ export { createTsxConfigFile, ensureTsxRegister, loadModule, resetModuleLoaderForTests };
@@ -0,0 +1,13 @@
1
+ interface TsxConfigOptions {
2
+ baseUrl: string;
3
+ paths: Record<string, string[]>;
4
+ fileName?: string;
5
+ }
6
+ declare function createTsxConfigFile(options: TsxConfigOptions): string;
7
+ declare function resetModuleLoaderForTests(): void;
8
+ declare function ensureTsxRegister(tsconfigPath?: string | null): Promise<void>;
9
+ declare function loadModule(file: string, options?: {
10
+ tsconfigPath?: string | null;
11
+ }): Promise<any>;
12
+
13
+ export { createTsxConfigFile, ensureTsxRegister, loadModule, resetModuleLoaderForTests };
@@ -0,0 +1,13 @@
1
+ interface TsxConfigOptions {
2
+ baseUrl: string;
3
+ paths: Record<string, string[]>;
4
+ fileName?: string;
5
+ }
6
+ declare function createTsxConfigFile(options: TsxConfigOptions): string;
7
+ declare function resetModuleLoaderForTests(): void;
8
+ declare function ensureTsxRegister(tsconfigPath?: string | null): Promise<void>;
9
+ declare function loadModule(file: string, options?: {
10
+ tsconfigPath?: string | null;
11
+ }): Promise<any>;
12
+
13
+ export { createTsxConfigFile, ensureTsxRegister, loadModule, resetModuleLoaderForTests };