Skip to content

Commit

Permalink
test: add packageJson BOM processing test case
Browse files Browse the repository at this point in the history
  • Loading branch information
sapenlei committed Dec 18, 2024
1 parent d6930cd commit 7c97a37
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
4 changes: 4 additions & 0 deletions playground/resolve/__tests__/resolve.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,3 +248,7 @@ test.runIf(isBuild)('public dir is not copied', async () => {
fs.existsSync(path.resolve(testDir, 'dist/should-not-be-copied')),
).toBe(false)
})

test('import utf8-bom package', async () => {
expect(await page.textContent('.utf8-bom-package')).toMatch('[success]')
})
6 changes: 6 additions & 0 deletions playground/resolve/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ <h2>resolve package that contains # in path</h2>
<h2>resolve non normalized absolute path</h2>
<p class="non-normalized"></p>

<h2>utf8-bom-package</h2>
<p class="utf8-bom-package">fail</p>

<script type="module">
import '@generated-content-virtual-file'
function text(selector, text) {
Expand Down Expand Up @@ -399,6 +402,9 @@ <h2>resolve non normalized absolute path</h2>

import nonNormalizedAbsolute from '@non-normalized'
text('.non-normalized', nonNormalizedAbsolute)

import { msg as utf8BomPackage } from '@vitejs/test-utf8-bom-package'
text('.utf8-bom-package', utf8BomPackage)
</script>

<style>
Expand Down
3 changes: 2 additions & 1 deletion playground/resolve/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"@vitejs/test-resolve-exports-with-module-condition-required": "link:./exports-with-module-condition-required",
"@vitejs/test-resolve-linked": "workspace:*",
"@vitejs/test-resolve-imports-pkg": "link:./imports-path/other-pkg",
"@vitejs/test-resolve-sharp-dir": "link:./sharp-dir"
"@vitejs/test-resolve-sharp-dir": "link:./sharp-dir",
"@vitejs/test-utf8-bom-package": "link:./utf8-bom-package"
}
}
3 changes: 3 additions & 0 deletions playground/resolve/utf8-bom-package/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import '@babel/runtime/helpers/esm/slicedToArray'

export const msg = '[success]'
8 changes: 8 additions & 0 deletions playground/resolve/utf8-bom-package/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "@vitejs/test-utf8-bom-package",
"private": true,
"version": "1.0.0",
"exports": {
".": "./index.mjs"
}
}

0 comments on commit 7c97a37

Please sign in to comment.