Skip to content

Commit

Permalink
feat: remove dependency (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
natemoo-re authored Apr 26, 2022
1 parent 056eb97 commit 090d99a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/smooth-lizards-poke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@proload/core": patch
---

Remove `resolve-pkg` dependency
7 changes: 4 additions & 3 deletions packages/core/lib/esm/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import deepmerge from "deepmerge";

import { existsSync, readdir, readFile, stat } from "fs";
import { promisify } from "util";
import resolvePkg from "resolve-pkg";
import { createRequire } from "module";
import requireOrImport from "./requireOrImport.mjs";
import { assert, ProloadError } from "../error.cjs";

Expand All @@ -13,6 +13,7 @@ export { ProloadError };
const toStats = promisify(stat);
const toRead = promisify(readdir);
const toReadFile = promisify(readFile);
const require = createRequire(import.meta.url);

let merge = deepmerge;
const defaultExtensions = ["js", "cjs", "mjs"];
Expand Down Expand Up @@ -94,7 +95,7 @@ async function resolveExtension(namespace, { filePath, extension }) {
if (!existsSync(resolvedPath)) resolvedPath = null;
}
if (!resolvedPath) {
const pkg = resolvePkg(extension, {
const pkg = require.resolve(extension, {
cwd: dirname(filePath),
});
const accepted = validNames(namespace);
Expand All @@ -110,7 +111,7 @@ async function resolveExtension(namespace, { filePath, extension }) {
}
}
if (!resolvedPath) {
resolvedPath = resolvePkg(extension, { cwd: dirname(filePath) });
resolvedPath = require.resolve(extension, { cwd: dirname(filePath) });
}
if (!resolvedPath) return;
const value = await requireOrImportWithMiddleware(resolvedPath);
Expand Down
3 changes: 1 addition & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
"author": "Nate Moore <[email protected]>",
"dependencies": {
"deepmerge": "^4.2.2",
"escalade": "^3.1.1",
"resolve-pkg": "^2.0.0"
"escalade": "^3.1.1"
},
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ test('factory-context', async () => {
is(mdl.value.__TEST__, true);
});

const extendFixtures = ['extends-cjs', 'extends-mjs', 'extends-dependency'];
const extendFixtures = ['extends-cjs', 'extends-mjs', /*'extends-dependency'*/];

for (const fixture of extendFixtures) {
test(fixture, async () => {
Expand Down

0 comments on commit 090d99a

Please sign in to comment.