Skip to content

Commit fa83ce9

Browse files
authored
Use enhanced-resolve for node resolution (#36)
This moves to using `enhanced-resolve` for resolving reporters in the CLI. Primarily because it is more up to date with the node resolution algorithm, but seems we dropped a few deep dependencies along the way too (which is good).
1 parent a0f0088 commit fa83ce9

File tree

4 files changed

+1193
-1023
lines changed

4 files changed

+1193
-1023
lines changed

fixtures/custom-reporter/node_modules/dual/package.json

+4-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/cli.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import path from 'path';
22
import fs from 'fs';
3-
import resolve from 'resolve';
3+
import resolve from 'enhanced-resolve';
44
import { command as createCommand, Error as CliError } from 'clap';
55
import * as reporters from './reporter/index.js';
66
import { validatePath, validateString } from './helpers.js';
@@ -29,6 +29,10 @@ function printResult(result, reporter) {
2929
}
3030
}
3131

32+
const nodeResolver = resolve.create.sync({
33+
conditionNames: ['node', 'import']
34+
});
35+
3236
const command = createCommand('csstree-validate [fileOrDir]')
3337
.version(version)
3438
.option(
@@ -43,7 +47,7 @@ const command = createCommand('csstree-validate [fileOrDir]')
4347

4448
if (!hasOwnProperty.call(reporters, nameOrFile)) {
4549
try {
46-
const resolvedPath = resolve.sync(nameOrFile, { basedir: process.cwd() });
50+
const resolvedPath = nodeResolver(process.cwd(), nameOrFile);
4751
return import(resolvedPath);
4852
} catch (e) {}
4953

0 commit comments

Comments
 (0)