-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
282 additions
and
13 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 |
---|---|---|
|
@@ -18,18 +18,7 @@ | |
"license": "MIT", | ||
"author": "Keith Cirkel <[email protected]> (http://keithcirkel.co.uk/)", | ||
"type": "module", | ||
"exports": { | ||
".": { | ||
"import": { | ||
"types": "./index.d.ts", | ||
"default": "./index.js" | ||
}, | ||
"require": { | ||
"types": "./index.d.ts", | ||
"default": "./index.cjs" | ||
} | ||
} | ||
}, | ||
"exports": {}, | ||
"types": "index.d.ts", | ||
"bin": "cli.js", | ||
"files": [ | ||
|
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,55 @@ | ||
import test from 'ava' | ||
import { macro } from './_helpers.js' | ||
|
||
for (const deep of [false, true]) { | ||
const titleSuffix = deep ? `(deep)` : '' | ||
|
||
{ | ||
const exports = { | ||
unknown: './unknown.unknown', | ||
'./path-not-really-makes-no-sense': {}, | ||
import: './import.mjs', | ||
types: './types.d.ts', | ||
} | ||
|
||
test(`'types' condition should be first${titleSuffix}`, macro.sortObject, { | ||
path: 'exports', | ||
expect: 'snapshot', | ||
value: deep ? { './deep': exports } : exports, | ||
}) | ||
} | ||
|
||
{ | ||
const exports = { | ||
unknown: './unknown.unknown', | ||
'./path-not-really-makes-no-sense': {}, | ||
default: './types.d.ts', | ||
import: './import.mjs', | ||
} | ||
|
||
test(`'default' condition should be last${titleSuffix}`, macro.sortObject, { | ||
path: 'exports', | ||
expect: 'snapshot', | ||
value: deep ? { './deep': exports } : exports, | ||
}) | ||
} | ||
|
||
{ | ||
const exports = { | ||
unknown: './unknown.unknown', | ||
require: './require.cjs', | ||
'./path-not-really-makes-no-sense': {}, | ||
'module-sync': './module-sync.mjs', | ||
} | ||
|
||
test( | ||
`'module-sync' condition should before 'require'${titleSuffix}`, | ||
macro.sortObject, | ||
{ | ||
path: 'exports', | ||
expect: 'snapshot', | ||
value: deep ? { './deep': exports } : exports, | ||
}, | ||
) | ||
} | ||
} |
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,167 @@ | ||
# Snapshot report for `tests/exports.js` | ||
|
||
The actual snapshot is saved in `exports.js.snap`. | ||
|
||
Generated by [AVA](https://avajs.dev). | ||
|
||
## 'types' condition should be first | ||
|
||
> Should sort `exports` as object. | ||
{ | ||
input: `{␊ | ||
"exports": {␊ | ||
"unknown": "./unknown.unknown",␊ | ||
"./path-not-really-makes-no-sense": {},␊ | ||
"import": "./import.mjs",␊ | ||
"types": "./types.d.ts"␊ | ||
}␊ | ||
}`, | ||
options: undefined, | ||
output: `{␊ | ||
"exports": {␊ | ||
"./path-not-really-makes-no-sense": {},␊ | ||
"types": "./types.d.ts",␊ | ||
"unknown": "./unknown.unknown",␊ | ||
"import": "./import.mjs"␊ | ||
}␊ | ||
}`, | ||
pretty: true, | ||
} | ||
|
||
## 'default' condition should be last | ||
|
||
> Should sort `exports` as object. | ||
{ | ||
input: `{␊ | ||
"exports": {␊ | ||
"unknown": "./unknown.unknown",␊ | ||
"./path-not-really-makes-no-sense": {},␊ | ||
"default": "./types.d.ts",␊ | ||
"import": "./import.mjs"␊ | ||
}␊ | ||
}`, | ||
options: undefined, | ||
output: `{␊ | ||
"exports": {␊ | ||
"./path-not-really-makes-no-sense": {},␊ | ||
"unknown": "./unknown.unknown",␊ | ||
"import": "./import.mjs",␊ | ||
"default": "./types.d.ts"␊ | ||
}␊ | ||
}`, | ||
pretty: true, | ||
} | ||
|
||
## 'module-sync' condition should before 'require' | ||
|
||
> Should sort `exports` as object. | ||
{ | ||
input: `{␊ | ||
"exports": {␊ | ||
"unknown": "./unknown.unknown",␊ | ||
"require": "./require.cjs",␊ | ||
"./path-not-really-makes-no-sense": {},␊ | ||
"module-sync": "./module-sync.mjs"␊ | ||
}␊ | ||
}`, | ||
options: undefined, | ||
output: `{␊ | ||
"exports": {␊ | ||
"./path-not-really-makes-no-sense": {},␊ | ||
"unknown": "./unknown.unknown",␊ | ||
"module-sync": "./module-sync.mjs",␊ | ||
"require": "./require.cjs"␊ | ||
}␊ | ||
}`, | ||
pretty: true, | ||
} | ||
|
||
## 'types' condition should be first(deep) | ||
|
||
> Should sort `exports` as object. | ||
{ | ||
input: `{␊ | ||
"exports": {␊ | ||
"./deep": {␊ | ||
"unknown": "./unknown.unknown",␊ | ||
"./path-not-really-makes-no-sense": {},␊ | ||
"import": "./import.mjs",␊ | ||
"types": "./types.d.ts"␊ | ||
}␊ | ||
}␊ | ||
}`, | ||
options: undefined, | ||
output: `{␊ | ||
"exports": {␊ | ||
"./deep": {␊ | ||
"./path-not-really-makes-no-sense": {},␊ | ||
"types": "./types.d.ts",␊ | ||
"unknown": "./unknown.unknown",␊ | ||
"import": "./import.mjs"␊ | ||
}␊ | ||
}␊ | ||
}`, | ||
pretty: true, | ||
} | ||
|
||
## 'default' condition should be last(deep) | ||
|
||
> Should sort `exports` as object. | ||
{ | ||
input: `{␊ | ||
"exports": {␊ | ||
"./deep": {␊ | ||
"unknown": "./unknown.unknown",␊ | ||
"./path-not-really-makes-no-sense": {},␊ | ||
"default": "./types.d.ts",␊ | ||
"import": "./import.mjs"␊ | ||
}␊ | ||
}␊ | ||
}`, | ||
options: undefined, | ||
output: `{␊ | ||
"exports": {␊ | ||
"./deep": {␊ | ||
"./path-not-really-makes-no-sense": {},␊ | ||
"unknown": "./unknown.unknown",␊ | ||
"import": "./import.mjs",␊ | ||
"default": "./types.d.ts"␊ | ||
}␊ | ||
}␊ | ||
}`, | ||
pretty: true, | ||
} | ||
|
||
## 'module-sync' condition should before 'require'(deep) | ||
|
||
> Should sort `exports` as object. | ||
{ | ||
input: `{␊ | ||
"exports": {␊ | ||
"./deep": {␊ | ||
"unknown": "./unknown.unknown",␊ | ||
"require": "./require.cjs",␊ | ||
"./path-not-really-makes-no-sense": {},␊ | ||
"module-sync": "./module-sync.mjs"␊ | ||
}␊ | ||
}␊ | ||
}`, | ||
options: undefined, | ||
output: `{␊ | ||
"exports": {␊ | ||
"./deep": {␊ | ||
"./path-not-really-makes-no-sense": {},␊ | ||
"unknown": "./unknown.unknown",␊ | ||
"module-sync": "./module-sync.mjs",␊ | ||
"require": "./require.cjs"␊ | ||
}␊ | ||
}␊ | ||
}`, | ||
pretty: true, | ||
} |
Binary file not shown.