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
11 changed files
with
60 additions
and
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
import { expect, test } from 'vitest' | ||
import { isBuild, testDir } from '~utils' | ||
import { isBuild, readFile, testDir } from '~utils' | ||
|
||
test.runIf(isBuild)('correctly resolve entrypoints', async () => { | ||
const { default: output } = await import(`${testDir}/dist/main.mjs`) | ||
const contents = readFile('dist/main.mjs') | ||
|
||
expect(output).toMatchInlineSnapshot(` | ||
" | ||
Matches: 5,7 | ||
React: 18.2.0 | ||
Lodash: true | ||
" | ||
`) | ||
const _ = `['"]` | ||
expect(contents).toMatch(new RegExp(`from ${_}entries/dir/index.js${_}`)) | ||
expect(contents).toMatch(new RegExp(`from ${_}entries/file.js${_}`)) | ||
expect(contents).toMatch(new RegExp(`from ${_}pkg-exports/entry${_}`)) | ||
|
||
await expect(import(`${testDir}/dist/main.mjs`)).resolves.toBeTruthy() | ||
}) |
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 @@ | ||
module.exports = __filename.slice(__filename.lastIndexOf('entries')) |
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 @@ | ||
module.exports = __filename.slice(__filename.lastIndexOf('entries')) |
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,5 @@ | ||
{ | ||
"name": "entries", | ||
"private": true, | ||
"version": "0.0.0" | ||
} |
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 |
---|---|---|
@@ -1,12 +1,12 @@ | ||
// no `exports` key, should resolve to autosuggest-highlight/match/index.js | ||
import match from 'autosuggest-highlight/match' | ||
// no `exports` key, should resolve to lodash/isInteger.js | ||
import isInteger from 'lodash/isInteger' | ||
// has `exports` key, should resolve to react-dom/server | ||
import { version } from 'react-dom/server' | ||
// no `exports` key, should resolve to entries/dir/index.js | ||
import dirEntry from 'entries/dir' | ||
// no `exports` key, should resolve to entries/file.js | ||
import fileEntry from 'entries/file' | ||
// has `exports` key, should resolve to pkg-exports/entry | ||
import pkgExportsEntry from 'pkg-exports/entry' | ||
|
||
export default ` | ||
Matches: ${match('some text', 'te')} | ||
React: ${version} | ||
Lodash: ${isInteger(42)} | ||
entries/dir: ${dirEntry} | ||
entries/file: ${fileEntry} | ||
pkg-exports/entry: ${pkgExportsEntry} | ||
` |
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 @@ | ||
module.exports = 'pkg-exports entry' |
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 @@ | ||
module.exports = undefined |
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,9 @@ | ||
{ | ||
"name": "pkg-exports", | ||
"private": true, | ||
"version": "0.0.0", | ||
"exports": { | ||
".": "./index.js", | ||
"./entry": "./entry.js" | ||
} | ||
} |
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.