mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-24 05:05:20 -04:00
(ts) apply tsconfig-path rewrites to scripts as well, server/calendar.ts was affected
see https://stackoverflow.com/questions/71571684/ts-node-with-tsconfig-paths-wont-work-when-using-esm
This commit is contained in:
parent
8bdc4438c1
commit
1ccca9bd98
15
server/load.js
Normal file
15
server/load.js
Normal file
@ -0,0 +1,15 @@
|
||||
import { resolve as resolveTs } from 'ts-node/esm.mjs';
|
||||
import { loadConfig, createMatchPath } from 'tsconfig-paths';
|
||||
import { pathToFileURL } from 'url';
|
||||
|
||||
const { absoluteBaseUrl, paths } = loadConfig();
|
||||
const matchPath = createMatchPath(absoluteBaseUrl, paths);
|
||||
|
||||
export async function resolve(specifier, ctx, defaultResolve) {
|
||||
const match = matchPath(specifier);
|
||||
return match
|
||||
? resolveTs(pathToFileURL(`${match}`).href, ctx, defaultResolve)
|
||||
: resolveTs(specifier, ctx, defaultResolve);
|
||||
}
|
||||
|
||||
export { load, transformSource } from 'ts-node/esm.mjs';
|
@ -1,4 +1,4 @@
|
||||
import { register } from 'node:module';
|
||||
import { pathToFileURL } from 'node:url';
|
||||
|
||||
register('ts-node/esm', pathToFileURL('./'));
|
||||
register('./server/load.js', pathToFileURL('./'));
|
||||
|
Loading…
x
Reference in New Issue
Block a user