Skip to content

Commit

Permalink
chore: core review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
mrm007 committed Sep 6, 2022
1 parent 8ade09d commit ebaaaf7
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 43 deletions.
17 changes: 8 additions & 9 deletions playground/ssr-resolve/__tests__/ssr-resolve.spec.ts
@@ -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()
})
1 change: 1 addition & 0 deletions playground/ssr-resolve/entries/dir/index.js
@@ -0,0 +1 @@
module.exports = __filename.slice(__filename.lastIndexOf('entries'))
1 change: 1 addition & 0 deletions playground/ssr-resolve/entries/file.js
@@ -0,0 +1 @@
module.exports = __filename.slice(__filename.lastIndexOf('entries'))
5 changes: 5 additions & 0 deletions playground/ssr-resolve/entries/package.json
@@ -0,0 +1,5 @@
{
"name": "entries",
"private": true,
"version": "0.0.0"
}
18 changes: 9 additions & 9 deletions playground/ssr-resolve/main.js
@@ -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}
`
6 changes: 2 additions & 4 deletions playground/ssr-resolve/package.json
Expand Up @@ -7,9 +7,7 @@
"debug": "node --inspect-brk ../../packages/vite/bin/vite build"
},
"dependencies": {
"autosuggest-highlight": "3.3.4",
"lodash": "4.17.21",
"react": "18.2.0",
"react-dom": "18.2.0"
"entries": "file:./entries",
"pkg-exports": "file:./pkg-exports"
}
}
1 change: 1 addition & 0 deletions playground/ssr-resolve/pkg-exports/entry.js
@@ -0,0 +1 @@
module.exports = 'pkg-exports entry'
1 change: 1 addition & 0 deletions playground/ssr-resolve/pkg-exports/index.js
@@ -0,0 +1 @@
module.exports = undefined
9 changes: 9 additions & 0 deletions playground/ssr-resolve/pkg-exports/package.json
@@ -0,0 +1,9 @@
{
"name": "pkg-exports",
"private": true,
"version": "0.0.0",
"exports": {
".": "./index.js",
"./entry": "./entry.js"
}
}
5 changes: 1 addition & 4 deletions playground/ssr-resolve/vite.config.js
Expand Up @@ -3,9 +3,6 @@ import { defineConfig } from 'vite'

export default defineConfig({
build: {
ssr: true,
rollupOptions: {
input: resolve(__dirname, 'main.js')
}
ssr: './main.js'
}
})
39 changes: 22 additions & 17 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ebaaaf7

Please sign in to comment.