1 | const resolve = require('resolve');
|
2 | const path = require('path');
|
3 |
|
4 | function opts(file, config) {
|
5 | return Object.assign(
|
6 | { extensions: ['.ts', '.tsx', '.d.ts'] },
|
7 | config,
|
8 |
|
9 | { basedir: path.dirname(path.resolve(file)) }
|
10 | );
|
11 | }
|
12 |
|
13 | module.exports = {
|
14 | interfaceVersion: 2,
|
15 | resolve: function(source, file, config) {
|
16 | if (resolve.isCore(source)) {
|
17 | return { found: true, path: null };
|
18 | }
|
19 |
|
20 | try {
|
21 | return { found: true, path: resolve.sync(source, opts(file, config)) };
|
22 | } catch (err) {
|
23 | return { found: false };
|
24 | }
|
25 | },
|
26 | };
|