aboutsummaryrefslogtreecommitdiffstats
path: root/loader.js
blob: e8f5036ed3ce0844440f24887330c5968adaf8de (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import path from 'path'
import fs from 'fs'

export function resolve (specifier, context, nextResolve) {
  const { parentURL = null } = context;

  if (specifier.startsWith('$')) {
    if (specifier.startsWith('$config')) {
      specifier = 'file://' + path.resolve('.') + "/config.js";
    }
    else if (specifier.startsWith('$')) { 
      specifier = specifier.replace(/^\$/, 'file://' + path.resolve('.') + '/') + '.js';
    }

    return {
      shortCircuit: true,
      url: new URL(specifier).href
    };
  } 

  return nextResolve(specifier, context)
}