Debian Codegraph @

test/integration/fixtures/esm/loader-with-module-not-found/loader-that-recognizes-ts.mjs

raw
1 import path from 'path'
2 import {fileURLToPath} from 'url'
3
4 /**
5 * @param {string} specifier
6 * @param {{
7 * conditions: !Array<string>,
8 * parentURL: !(string | undefined),
9 * }} context
10 * @param {Function} defaultResolve
11 * @returns {Promise<{ url: string }>}
12 */
13 export async function resolve(specifier, context, defaultResolve) {
14 const extension = path.extname(
15 fileURLToPath(/**@type {import('url').URL}*/ (new URL(specifier, context.parentURL))),
16 )
17 return await defaultResolve(specifier.replace('.ts', '.mjs'), context, defaultResolve)
18 }