-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix circular dependency in
lib/get-format.js
Closes GH-13. Reviewed-by: Titus Wormer <tituswormer@gmail.com>
- Loading branch information
Showing
3 changed files
with
27 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Manually “tree shaken” from: | ||
// <https://github.com/nodejs/node/blob/6668c4d/lib/internal/modules/esm/resolve.js> | ||
// Last checked on: Jan 6, 2023. | ||
// | ||
// This file solves a circular dependency. | ||
// In Node.js, `getPackageType` is in `resolve.js`. | ||
// `resolve.js` imports `get-format.js`, which needs `getPackageType`. | ||
// We split that up so that bundlers don’t fail. | ||
|
||
/** | ||
* @typedef {import('./package-config.js').PackageType} PackageType | ||
*/ | ||
|
||
import {getPackageScopeConfig} from './package-config.js' | ||
|
||
/** | ||
* @param {URL} url | ||
* @returns {PackageType} | ||
*/ | ||
export function getPackageType(url) { | ||
const packageConfig = getPackageScopeConfig(url) | ||
return packageConfig.type | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters