-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
16 changed files
with
337 additions
and
90 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
packages/playground/import-glob/__tests__/import-context.spec.ts
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,49 @@ | ||
import { isBuild } from '../../testUtils' | ||
|
||
const filteredResult = { | ||
'./foo.js': { | ||
msg: 'foo' | ||
} | ||
} | ||
|
||
// json exports key order is altered during build, but it doesn't matter in | ||
// terms of behavior since module exports are not ordered anyway | ||
const json = isBuild | ||
? { | ||
msg: 'baz', | ||
default: { | ||
msg: 'baz' | ||
} | ||
} | ||
: { | ||
default: { | ||
msg: 'baz' | ||
}, | ||
msg: 'baz' | ||
} | ||
|
||
const allResult = { | ||
// JSON file should be properly transformed | ||
'./dir/baz.json': json, | ||
'./dir/foo.js': { | ||
msg: 'foo' | ||
}, | ||
'./dir/index.js': { | ||
default: filteredResult | ||
}, | ||
'./dir/nested/bar.js': { | ||
msg: 'bar' | ||
} | ||
} | ||
|
||
test('all', async () => { | ||
expect(await page.textContent('.all')).toBe( | ||
JSON.stringify(allResult, null, 2) | ||
) | ||
}) | ||
|
||
test('filtered', async () => { | ||
expect(await page.textContent('.filtered')).toBe( | ||
JSON.stringify(filteredResult, null, 2) | ||
) | ||
}) |
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,3 @@ | ||
{ | ||
"msg": "baz" | ||
} |
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 @@ | ||
export const msg = 'foo' |
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 @@ | ||
import modules from 'glob:./*.js' | ||
|
||
document.querySelector('.filtered').textContent = JSON.stringify( | ||
modules, | ||
null, | ||
2 | ||
) | ||
|
||
export default modules |
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 @@ | ||
export const msg = 'bar' |
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,12 @@ | ||
<h2>All (./dir/**)</h2> | ||
<pre class="all"></pre> | ||
|
||
<h2>Filtered (./*.js from dir/index.js)</h2> | ||
<pre class="filtered"></pre> | ||
|
||
<script type="module" src="./dir/index.js"></script> | ||
<script type="module"> | ||
import modules from 'glob:./dir/**' | ||
|
||
document.querySelector('.all').textContent = JSON.stringify(modules, null, 2) | ||
</script> |
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,10 @@ | ||
{ | ||
"name": "test-import-context", | ||
"private": true, | ||
"version": "0.0.0", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "vite build", | ||
"debug": "node --inspect-brk ../../vite/bin/vite" | ||
} | ||
} |
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
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.