-
Notifications
You must be signed in to change notification settings - Fork 4
/
loader.js
26 lines (23 loc) · 803 Bytes
/
loader.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/* eslint-disable import/no-extraneous-dependencies */
import { dirname } from 'dirname-filename-esm'
import { pathToFileURL } from 'url'
import path from 'path'
const specifierMap = {
haetae: 'packages/haetae/src/index.js',
'@haetae/cli': 'packages/cli/src/index.js',
'@haetae/common': 'packages/common/src/index.js',
'@haetae/core': 'packages/core/src/index.js',
'@haetae/git': 'packages/git/src/index.js',
'@haetae/javascript': 'packages/js/src/index.js',
'@haetae/utils': 'packages/utils/src/index.js',
}
export function resolve(specifier, context, nextResolve) {
if (specifierMap[specifier]) {
return nextResolve(
pathToFileURL(path.join(dirname(import.meta), specifierMap[specifier]))
.href,
context,
)
}
return nextResolve(specifier, context)
}