Skip to content

Commit

Permalink
Revert "Remove resolve-pkg dependency (#16)"
Browse files Browse the repository at this point in the history
This reverts commit 5cbbe02.
  • Loading branch information
Nate Moore committed Apr 26, 2022
1 parent 6e37e52 commit e49aef6
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 35 deletions.
5 changes: 0 additions & 5 deletions .changeset/early-boats-approve.md

This file was deleted.

20 changes: 0 additions & 20 deletions .changeset/pre.json

This file was deleted.

4 changes: 0 additions & 4 deletions packages/core/lib/cjs/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ const { ProloadError } = require('../error.cjs');
function load(...args) {
return import('../esm/index.mjs').then(({ default: loader }) => loader(...args));
}
function resolve(...args) {
return import('../esm/index.mjs').then(({ resolve: resolver }) => resolver(...args));
}

load.resolve = resolve;
load.default = load;
load.ProloadError = ProloadError;
module.exports = load;
7 changes: 3 additions & 4 deletions packages/core/lib/esm/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import deepmerge from "deepmerge";

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

export { ProloadError };

const require = createRequire(import.meta.url);
const toStats = promisify(stat);
const toRead = promisify(readdir);
const toReadFile = promisify(readFile);
Expand Down Expand Up @@ -95,7 +94,7 @@ async function resolveExtension(namespace, { filePath, extension }) {
if (!existsSync(resolvedPath)) resolvedPath = null;
}
if (!resolvedPath) {
const pkg = require.resolve(extension, {
const pkg = resolvePkg(extension, {
cwd: dirname(filePath),
});
const accepted = validNames(namespace);
Expand All @@ -111,7 +110,7 @@ async function resolveExtension(namespace, { filePath, extension }) {
}
}
if (!resolvedPath) {
resolvedPath = require.resolve(extension, { cwd: dirname(filePath) });
resolvedPath = resolvePkg(extension, { cwd: dirname(filePath) });
}
if (!resolvedPath) return;
const value = await requireOrImportWithMiddleware(resolvedPath);
Expand Down
7 changes: 6 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
"import": "./lib/esm/index.mjs",
"require": "./lib/cjs/index.cjs"
},
"./plugin-typescript": {
"import": "./plugin-typescript/index.mjs",
"require": "./plugin-typescript/index.cjs"
},
"./esm": "./lib/esm/index.mjs",
"./cjs": "./lib/cjs/index.cjs",
"./lib/index.d.ts": "./lib/index.d.ts",
Expand All @@ -31,7 +35,8 @@
"author": "Nate Moore <[email protected]>",
"dependencies": {
"deepmerge": "^4.2.2",
"escalade": "^3.1.1"
"escalade": "^3.1.1",
"resolve-pkg": "^2.0.0"
},
"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
7 changes: 7 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1481,6 +1481,13 @@ resolve-from@^5.0.0:
resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-5.0.0.tgz#c35225843df8f776df21c57557bc087e9dfdfc69"
integrity sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==

resolve-pkg@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/resolve-pkg/-/resolve-pkg-2.0.0.tgz#ac06991418a7623edc119084edc98b0e6bf05a41"
integrity sha512-+1lzwXehGCXSeryaISr6WujZzowloigEofRB+dj75y9RRa/obVcYgbHJd53tdYw8pvZj8GojXaaENws8Ktw/hQ==
dependencies:
resolve-from "^5.0.0"

resolve@^1.10.0:
version "1.20.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.20.0.tgz#629a013fb3f70755d6f0b7935cc1c2c5378b1975"
Expand Down

0 comments on commit e49aef6

Please sign in to comment.