Skip to content

Commit

Permalink
chore(tests): add a resolve test for nested package scopes
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist committed Dec 29, 2022
1 parent dc03c54 commit de249e7
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 0 deletions.
6 changes: 6 additions & 0 deletions playground/resolve/__tests__/resolve.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ test('deep import', async () => {
expect(await page.textContent('.deep-import')).toMatch('[2,4]')
})

test('exports and a nested package scope with a different type', async () => {
expect(await page.textContent('.exports-and-nested-scope')).toMatch(
'[success]',
)
})

test('entry with exports field', async () => {
expect(await page.textContent('.exports-entry')).toMatch('[success]')
})
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict'

Object.defineProperty(exports, '__esModule', {
value: true,
})
exports.msg = void 0
var msg =
'[success] commonjs .js file within root that has type: module (thanks to a package scope)'
exports.msg = msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"private": true,
"type": "commonjs"
}
10 changes: 10 additions & 0 deletions playground/resolve/exports-and-nested-scope/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "@vitejs/test-resolve-exports-and-nested-scope",
"private": true,
"version": "1.0.0",
"type": "module",
"exports": {
".": "./index.js",
"./nested": "./nested-scope/file.js"
}
}
6 changes: 6 additions & 0 deletions playground/resolve/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ <h2>Utf8-bom import</h2>
<h2>Deep import</h2>
<p>Should show [2,4]:<span class="pre deep-import">fail</span></p>

<h2>Exports and a nested package scope with a different type</h2>
<p class="exports-and-nested-scope">fail</p>

<h2>Entry resolving with exports field</h2>
<p class="exports-entry">fail</p>

Expand Down Expand Up @@ -146,6 +149,9 @@ <h2>resolve package that contains # in path</h2>

text('.deep-import', JSON.stringify(slicedToArray(iterable, 2)))

import exportsAndNestedScope from '@vitejs/test-resolve-exports-and-nested-scope/nested'
text('.exports-and-nested-scope', exportsAndNestedScope.msg)

// exports field
import { msg } from '@vitejs/test-resolve-exports-path'
text('.exports-entry', msg)
Expand Down
1 change: 1 addition & 0 deletions playground/resolve/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@vitejs/test-resolve-browser-module-field3": "link:./browser-module-field3",
"@vitejs/test-resolve-custom-condition": "link:./custom-condition",
"@vitejs/test-resolve-custom-main-field": "link:./custom-main-field",
"@vitejs/test-resolve-exports-and-nested-scope": "link:./exports-and-nested-scope",
"@vitejs/test-resolve-exports-env": "link:./exports-env",
"@vitejs/test-resolve-exports-from-root": "link:./exports-from-root",
"@vitejs/test-resolve-exports-legacy-fallback": "link:./exports-legacy-fallback",
Expand Down
8 changes: 8 additions & 0 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 de249e7

Please sign in to comment.