-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(packageparser): remove support for invalid
exports
shapes (#336)
- Loading branch information
Showing
19 changed files
with
206 additions
and
107 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,7 @@ | ||
declare module '@babel/plugin-syntax-import-assertions' { | ||
export default Record<string, unknown>; | ||
} | ||
|
||
declare module 'rollup-plugin-preserve-shebang' { | ||
export default function(): unknown; | ||
} |
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
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,72 @@ | ||
export type PackageJSONVersion = `${ number}.${ number }.${ number }`; | ||
|
||
export type PackageJSONSubPath = '.' | `.${ string }`; | ||
|
||
export interface PackageJSONConditionalExport { | ||
readonly import: string; | ||
readonly types?: string; | ||
readonly requires?: string; | ||
} | ||
|
||
export type PackageJSONSubPathExports = Readonly<Record<PackageJSONSubPath, string | PackageJSONConditionalExport>>; | ||
|
||
export type PackageJSONExports = | ||
| string | ||
| PackageJSONSubPathExports | ||
| PackageJSONConditionalExport; | ||
|
||
export type PackageJSONAuthor = string | { | ||
name: string; | ||
}; | ||
|
||
export type PackageJSONBin = string | Record<string, string>; | ||
|
||
export interface PackageJSONEngines { | ||
readonly node?: string; | ||
} | ||
|
||
export interface PackageJSON { | ||
readonly name: string; | ||
readonly version: PackageJSONVersion; | ||
readonly author: PackageJSONAuthor; | ||
readonly license: string; | ||
readonly exports: PackageJSONExports; | ||
readonly bin?: PackageJSONBin; | ||
readonly engines?: PackageJSONEngines; | ||
} | ||
|
||
export function isConditionalExport( obj: unknown ): obj is PackageJSONConditionalExport { | ||
if ( obj === undefined || obj === null ) { | ||
return false; | ||
} | ||
|
||
const keys = Object.keys( obj ); | ||
|
||
if ( keys.length === 0 ) { | ||
return false; | ||
} | ||
|
||
return keys.every( ( key ) => { | ||
return key === 'import' || key === 'types' || key === 'require'; | ||
} ); | ||
} | ||
|
||
export function isSubPathExports( obj: unknown ): obj is PackageJSONSubPathExports { | ||
if ( obj === undefined || obj === null ) { | ||
return false; | ||
} | ||
|
||
const keys = Object.keys( obj ); | ||
|
||
if ( keys.length === 0 ) { | ||
return false; | ||
} | ||
|
||
return keys.every( ( key ) => { | ||
return isSubPath( key ); | ||
} ); | ||
} | ||
|
||
export function isSubPath( value: unknown ): value is PackageJSONSubPath { | ||
return typeof value === 'string' && value.startsWith( '.' ); | ||
} |
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
Oops, something went wrong.