Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/vite/src/node/__tests__/config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1798,6 +1798,7 @@ describe('loadConfigFromFile', () => {
{ command: 'build', mode: 'production' },
undefined,
root,
'silent',
)
expect(result).toBeTruthy()
expect(result?.config).toStrictEqual({ define: { foo: 1 } })
Expand Down Expand Up @@ -1910,6 +1911,7 @@ describe('loadConfigFromFile', () => {
{} as any,
path.resolve(fixtures, './cjs-module-vars-in-esm/vite.config.ts'),
path.resolve(fixtures, './cjs-module-vars-in-esm'),
'silent',
))!
const c = config as any
expect(c.dirname).toContain('cjs-module-vars-in-esm')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@ import { resolve } from 'node:path'
import { promises as fs } from 'node:fs'
import { describe, expect, it } from 'vitest'
import { transformGlobImport } from '../../../plugins/importMetaGlob'
import { transformWithEsbuild } from '../../../plugins/esbuild'
import { transformWithOxc } from '../../../plugins/oxc'

describe('fixture', async () => {
const resolveId = (id: string) => id
const root = import.meta.dirname

it('transform', async () => {
const id = resolve(import.meta.dirname, './fixture-a/index.ts')
const code = (
await transformWithEsbuild(await fs.readFile(id, 'utf-8'), id)
).code
const code = (await transformWithOxc(await fs.readFile(id, 'utf-8'), id))
.code

expect(
(await transformGlobImport(code, id, root, resolveId))?.s.toString(),
Expand Down Expand Up @@ -81,9 +80,8 @@ describe('fixture', async () => {

it('transform with restoreQueryExtension', async () => {
const id = resolve(import.meta.dirname, './fixture-a/index.ts')
const code = (
await transformWithEsbuild(await fs.readFile(id, 'utf-8'), id)
).code
const code = (await transformWithOxc(await fs.readFile(id, 'utf-8'), id))
.code

expect(
(
Expand Down
12 changes: 7 additions & 5 deletions packages/vite/src/node/ssr/__tests__/ssrTransform.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { fileURLToPath } from 'node:url'
import { assert, expect, test } from 'vitest'
import type { SourceMap } from 'rolldown'
import { TraceMap, originalPositionFor } from '@jridgewell/trace-mapping'
import { transformWithEsbuild } from '../../plugins/esbuild'
import { transformWithOxc } from '../../plugins/oxc'
import { ssrTransform } from '../ssrTransform'
import { createServer } from '../..'

Expand Down Expand Up @@ -1067,15 +1067,17 @@ test('jsx', async () => {
}
`
const id = '/foo.jsx'
const result = await transformWithEsbuild(code, id)
const result = await transformWithOxc(code, id, {
jsx: { runtime: 'classic' },
})
expect(await ssrTransformSimpleCode(result.code, '/foo.jsx'))
.toMatchInlineSnapshot(`
"const __vite_ssr_import_0__ = await __vite_ssr_import__("react", {"importedNames":["default"]});
const __vite_ssr_import_1__ = await __vite_ssr_import__("foo", {"importedNames":["Foo","Slot"]});
function Bar({ Slot: Slot2 = /* @__PURE__ */ __vite_ssr_import_0__.default.createElement((0,__vite_ssr_import_1__.Foo), null) }) {
return /* @__PURE__ */ __vite_ssr_import_0__.default.createElement(__vite_ssr_import_0__.default.Fragment, null, /* @__PURE__ */ __vite_ssr_import_0__.default.createElement(Slot2, null));
function Bar({ Slot = /* @__PURE__ */ __vite_ssr_import_0__.default.createElement((0,__vite_ssr_import_1__.Foo), null) }) {
return /* @__PURE__ */ __vite_ssr_import_0__.default.createElement(__vite_ssr_import_0__.default.Fragment, null, /* @__PURE__ */ __vite_ssr_import_0__.default.createElement(Slot, null));
}
"
`)
Expand Down Expand Up @@ -1103,7 +1105,7 @@ export function fn1() {

// https://github.com/vitest-dev/vitest/issues/1141
test('export default expression', async () => {
// esbuild transform result of following TS code
// Oxc transform result of following TS code
// export default <MyFn> function getRandom() {
// return Math.random()
// }
Expand Down
2 changes: 1 addition & 1 deletion playground/fs-serve/root/windows83Filename.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function getWindows83ShortName(inputPath: string): string | undefined {
try {
const result = execSync(
`powershell -Command "(New-Object -ComObject Scripting.FileSystemObject).GetFile('${inputPath}').ShortPath"`,
{ encoding: 'utf-8' },
{ encoding: 'utf-8', stdio: 'pipe' },
).trim()
return result !== inputPath && result.includes('~') ? result : undefined
} catch {
Expand Down
4 changes: 4 additions & 0 deletions pnpm-lock.yaml

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