From 4561386365ad32de8df201dd1efd19d5adc26133 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Thu, 4 Jan 2024 15:09:27 +0900 Subject: [PATCH 1/7] fix: apply resolve.alias to external library during dev ssr --- packages/vite/src/node/plugins/preAlias.ts | 8 ++++++++ packages/vite/src/node/ssr/ssrExternal.ts | 4 +++- playground/ssr-deps/__tests__/ssr-deps.spec.ts | 5 +++++ playground/ssr-deps/alias/index.js | 1 + playground/ssr-deps/alias/package.json | 9 +++++++++ playground/ssr-deps/package.json | 1 + playground/ssr-deps/server.js | 5 +++++ playground/ssr-deps/src/alias-replaced.js | 1 + playground/ssr-deps/src/app.js | 3 +++ pnpm-lock.yaml | 10 ++++++++++ 10 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 playground/ssr-deps/alias/index.js create mode 100644 playground/ssr-deps/alias/package.json create mode 100644 playground/ssr-deps/src/alias-replaced.js diff --git a/packages/vite/src/node/plugins/preAlias.ts b/packages/vite/src/node/plugins/preAlias.ts index 33df60b2d58b2e..fce49c821d5332 100644 --- a/packages/vite/src/node/plugins/preAlias.ts +++ b/packages/vite/src/node/plugins/preAlias.ts @@ -129,3 +129,11 @@ function getAliasPatterns( } return Object.entries(entries).map(([find]) => find) } + +export function getAliasPatternMatcher( + entries: (AliasOptions | undefined) & Alias[], +): (importee: string) => boolean { + const patterns = getAliasPatterns(entries) + return (importee: string) => + patterns.some((pattern) => matches(pattern, importee)) +} diff --git a/packages/vite/src/node/ssr/ssrExternal.ts b/packages/vite/src/node/ssr/ssrExternal.ts index 5681e000502a5f..9058a613e760fe 100644 --- a/packages/vite/src/node/ssr/ssrExternal.ts +++ b/packages/vite/src/node/ssr/ssrExternal.ts @@ -9,6 +9,7 @@ import { isBuiltin, } from '../utils' import type { ResolvedConfig } from '..' +import { getAliasPatternMatcher } from '../plugins/preAlias' const debug = createDebugger('vite:ssr-external') @@ -125,13 +126,14 @@ function createIsSsrExternal( const processedIds = new Map() const isConfiguredAsExternal = createIsConfiguredAsSsrExternal(config) + const matchAlias = getAliasPatternMatcher(config.resolve.alias) return (id: string, importer?: string) => { if (processedIds.has(id)) { return processedIds.get(id) } let external = false - if (id[0] !== '.' && !path.isAbsolute(id)) { + if (id[0] !== '.' && !path.isAbsolute(id) && !matchAlias(id)) { external = isBuiltin(id) || isConfiguredAsExternal(id, importer) } processedIds.set(id, external) diff --git a/playground/ssr-deps/__tests__/ssr-deps.spec.ts b/playground/ssr-deps/__tests__/ssr-deps.spec.ts index c8794ce915dc21..0aa357c2e673e6 100644 --- a/playground/ssr-deps/__tests__/ssr-deps.spec.ts +++ b/playground/ssr-deps/__tests__/ssr-deps.spec.ts @@ -119,6 +119,11 @@ test('import css library', async () => { expect(await page.textContent('.module-condition')).toMatch('[success]') }) +test('apply resolve.alias to library accessible as external', async () => { + await page.goto(url) + expect(await page.textContent('.alias')).toMatch('alias-replaced') +}) + describe.runIf(isServe)('hmr', () => { test('handle isomorphic module updates', async () => { await page.goto(url) diff --git a/playground/ssr-deps/alias/index.js b/playground/ssr-deps/alias/index.js new file mode 100644 index 00000000000000..1f2c059de4189d --- /dev/null +++ b/playground/ssr-deps/alias/index.js @@ -0,0 +1 @@ +export default 'test-alias-original' diff --git a/playground/ssr-deps/alias/package.json b/playground/ssr-deps/alias/package.json new file mode 100644 index 00000000000000..5c7bfa503e2a21 --- /dev/null +++ b/playground/ssr-deps/alias/package.json @@ -0,0 +1,9 @@ +{ + "name": "@vitejs/test-alias", + "private": true, + "version": "0.0.0", + "exports": { + ".": "./index.js" + }, + "type": "module" +} diff --git a/playground/ssr-deps/package.json b/playground/ssr-deps/package.json index e861b9c51815e1..39f242f30df6cf 100644 --- a/playground/ssr-deps/package.json +++ b/playground/ssr-deps/package.json @@ -30,6 +30,7 @@ "@vitejs/test-external-entry": "file:./external-entry", "@vitejs/test-linked-no-external": "link:./linked-no-external", "@vitejs/test-pkg-exports": "file:./pkg-exports", + "@vitejs/test-alias": "file:./alias", "@vitejs/test-module-condition": "file:./module-condition" }, "devDependencies": { diff --git a/playground/ssr-deps/server.js b/playground/ssr-deps/server.js index 05e86a863ea744..c18e89d6f35963 100644 --- a/playground/ssr-deps/server.js +++ b/playground/ssr-deps/server.js @@ -34,6 +34,11 @@ export async function createServer(root = process.cwd(), hmrPort) { }, }, appType: 'custom', + resolve: { + alias: { + '@vitejs/test-alias': '/src/alias-replaced.js', + }, + }, ssr: { noExternal: [ '@vitejs/test-no-external-cjs', diff --git a/playground/ssr-deps/src/alias-replaced.js b/playground/ssr-deps/src/alias-replaced.js new file mode 100644 index 00000000000000..6ff1ede37eb867 --- /dev/null +++ b/playground/ssr-deps/src/alias-replaced.js @@ -0,0 +1 @@ +export default 'alias-replaced' diff --git a/playground/ssr-deps/src/app.js b/playground/ssr-deps/src/app.js index 719c6eec7e8205..455b417b3e35ad 100644 --- a/playground/ssr-deps/src/app.js +++ b/playground/ssr-deps/src/app.js @@ -16,6 +16,7 @@ import importBuiltinCjs from '@vitejs/test-import-builtin-cjs' import { hello as linkedNoExternal } from '@vitejs/test-linked-no-external' import virtualMessage from '@vitejs/test-pkg-exports/virtual' import moduleConditionMessage from '@vitejs/test-module-condition' +import testAlias from '@vitejs/test-alias' import '@vitejs/test-css-lib' // This import will set a 'Hello World!" message in the nested-external non-entry dependency @@ -90,6 +91,8 @@ export async function render(url, rootDir) { html += `\n

${moduleConditionMessage}

` + html += `\n

message from alias: ${testAlias}

` + html += `\n

${isomorphicModuleMessage}

` html += `\n

` diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 378838eefda642..1c4adb4bf41055 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1247,6 +1247,9 @@ importers: playground/ssr-deps: dependencies: + '@vitejs/test-alias': + specifier: file:./alias + version: file:playground/ssr-deps/alias '@vitejs/test-css-lib': specifier: file:./css-lib version: file:playground/ssr-deps/css-lib @@ -1318,6 +1321,8 @@ importers: specifier: ^4.18.2 version: 4.18.2 + playground/ssr-deps/alias: {} + playground/ssr-deps/css-lib: {} playground/ssr-deps/define-properties-exports: {} @@ -9851,6 +9856,11 @@ packages: name: '@vitejs/test-ssr-conditions-no-external' dev: false + file:playground/ssr-deps/alias: + resolution: {directory: playground/ssr-deps/alias, type: directory} + name: '@vitejs/test-alias' + dev: false + file:playground/ssr-deps/css-lib: resolution: {directory: playground/ssr-deps/css-lib, type: directory} name: '@vitejs/test-css-lib' From da5af5dac8540600dd2ae9ceb0d8b912cedc57eb Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Thu, 4 Jan 2024 15:21:03 +0900 Subject: [PATCH 2/7] test: tweak --- playground/ssr-deps/__tests__/ssr-deps.spec.ts | 3 ++- playground/ssr-deps/alias/index.js | 2 +- playground/ssr-deps/server.js | 1 + playground/ssr-deps/src/app.js | 2 ++ 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/playground/ssr-deps/__tests__/ssr-deps.spec.ts b/playground/ssr-deps/__tests__/ssr-deps.spec.ts index 0aa357c2e673e6..30e8166d9bf7bb 100644 --- a/playground/ssr-deps/__tests__/ssr-deps.spec.ts +++ b/playground/ssr-deps/__tests__/ssr-deps.spec.ts @@ -119,8 +119,9 @@ test('import css library', async () => { expect(await page.textContent('.module-condition')).toMatch('[success]') }) -test('apply resolve.alias to library accessible as external', async () => { +test('resolve.alias', async () => { await page.goto(url) + expect(await page.textContent('.alias-no-exist')).toMatch('alias-replaced') expect(await page.textContent('.alias')).toMatch('alias-replaced') }) diff --git a/playground/ssr-deps/alias/index.js b/playground/ssr-deps/alias/index.js index 1f2c059de4189d..6c09384100a1c0 100644 --- a/playground/ssr-deps/alias/index.js +++ b/playground/ssr-deps/alias/index.js @@ -1 +1 @@ -export default 'test-alias-original' +export default 'alias-original' diff --git a/playground/ssr-deps/server.js b/playground/ssr-deps/server.js index c18e89d6f35963..90fc1a8ad7bedc 100644 --- a/playground/ssr-deps/server.js +++ b/playground/ssr-deps/server.js @@ -37,6 +37,7 @@ export async function createServer(root = process.cwd(), hmrPort) { resolve: { alias: { '@vitejs/test-alias': '/src/alias-replaced.js', + '@vitejs/test-alias-no-exist': '/src/alias-replaced.js', }, }, ssr: { diff --git a/playground/ssr-deps/src/app.js b/playground/ssr-deps/src/app.js index 455b417b3e35ad..b4e775241b09f6 100644 --- a/playground/ssr-deps/src/app.js +++ b/playground/ssr-deps/src/app.js @@ -17,6 +17,7 @@ import { hello as linkedNoExternal } from '@vitejs/test-linked-no-external' import virtualMessage from '@vitejs/test-pkg-exports/virtual' import moduleConditionMessage from '@vitejs/test-module-condition' import testAlias from '@vitejs/test-alias' +import testAliasNoExist from '@vitejs/test-alias-no-exist' import '@vitejs/test-css-lib' // This import will set a 'Hello World!" message in the nested-external non-entry dependency @@ -92,6 +93,7 @@ export async function render(url, rootDir) { html += `\n

${moduleConditionMessage}

` html += `\n

message from alias: ${testAlias}

` + html += `\n

message from alias-no-exist: ${testAliasNoExist}

` html += `\n

${isomorphicModuleMessage}

` From cbdb4e8ec96b24477f5a36f87c317b249546ad1e Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Mon, 15 Jan 2024 10:01:36 +0900 Subject: [PATCH 3/7] test: test both dev and build --- .../ssr-alias/__tests__/ssr-alias.spec.ts | 20 +++++++++++++++++++ playground/ssr-alias/alias-original/index.js | 1 + .../ssr-alias/alias-original/package.json | 9 +++++++++ playground/ssr-alias/package.json | 12 +++++++++++ playground/ssr-alias/src/alias-process.js | 3 +++ playground/ssr-alias/src/alias-replaced.js | 1 + playground/ssr-alias/src/main.js | 9 +++++++++ playground/ssr-alias/vite.config.js | 14 +++++++++++++ 8 files changed, 69 insertions(+) create mode 100644 playground/ssr-alias/__tests__/ssr-alias.spec.ts create mode 100644 playground/ssr-alias/alias-original/index.js create mode 100644 playground/ssr-alias/alias-original/package.json create mode 100644 playground/ssr-alias/package.json create mode 100644 playground/ssr-alias/src/alias-process.js create mode 100644 playground/ssr-alias/src/alias-replaced.js create mode 100644 playground/ssr-alias/src/main.js create mode 100644 playground/ssr-alias/vite.config.js diff --git a/playground/ssr-alias/__tests__/ssr-alias.spec.ts b/playground/ssr-alias/__tests__/ssr-alias.spec.ts new file mode 100644 index 00000000000000..93001865ce84e5 --- /dev/null +++ b/playground/ssr-alias/__tests__/ssr-alias.spec.ts @@ -0,0 +1,20 @@ +import { expect, test } from 'vitest' +import { isServe, testDir, viteServer } from '~utils' + +test.runIf(isServe)('dev', async () => { + const mod = await viteServer.ssrLoadModule('/src/main.js') + expect(mod.default).toEqual({ + dep: 'ok', + nonDep: 'ok', + builtin: 'ok', + }) +}) + +test.runIf(!isServe)('build', async () => { + const mod = await import(`${testDir}/dist/main.js`) + expect(mod.default).toEqual({ + dep: 'ok', + nonDep: 'ok', + builtin: 'ok', + }) +}) diff --git a/playground/ssr-alias/alias-original/index.js b/playground/ssr-alias/alias-original/index.js new file mode 100644 index 00000000000000..cc9a88ac598de3 --- /dev/null +++ b/playground/ssr-alias/alias-original/index.js @@ -0,0 +1 @@ +export default 'original' diff --git a/playground/ssr-alias/alias-original/package.json b/playground/ssr-alias/alias-original/package.json new file mode 100644 index 00000000000000..a8a86b500b90fa --- /dev/null +++ b/playground/ssr-alias/alias-original/package.json @@ -0,0 +1,9 @@ +{ + "name": "@vitejs/test-alias-original", + "version": "0.0.0", + "private": true, + "type": "module", + "exports": { + ".": "./index.js" + } +} diff --git a/playground/ssr-alias/package.json b/playground/ssr-alias/package.json new file mode 100644 index 00000000000000..f765f8ac70d60b --- /dev/null +++ b/playground/ssr-alias/package.json @@ -0,0 +1,12 @@ +{ + "name": "@vitejs/test-ssr-html", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "build": "vite build" + }, + "dependencies": { + "@vitejs/test-alias-original": "file:./alias-original" + } +} diff --git a/playground/ssr-alias/src/alias-process.js b/playground/ssr-alias/src/alias-process.js new file mode 100644 index 00000000000000..9cd9e7ddeb637d --- /dev/null +++ b/playground/ssr-alias/src/alias-process.js @@ -0,0 +1,3 @@ +export default { + env: { __TEST_ALIAS__: 'ok' }, +} diff --git a/playground/ssr-alias/src/alias-replaced.js b/playground/ssr-alias/src/alias-replaced.js new file mode 100644 index 00000000000000..60c71f346d9a3e --- /dev/null +++ b/playground/ssr-alias/src/alias-replaced.js @@ -0,0 +1 @@ +export default 'ok' diff --git a/playground/ssr-alias/src/main.js b/playground/ssr-alias/src/main.js new file mode 100644 index 00000000000000..957cd605ef6ba2 --- /dev/null +++ b/playground/ssr-alias/src/main.js @@ -0,0 +1,9 @@ +import dep from '@vitejs/test-alias-original' +import nonDep from '@vitejs/test-alias-non-dep' +import process from 'node:process' + +export default { + dep, + nonDep, + builtin: process.env['__TEST_ALIAS__'], +} diff --git a/playground/ssr-alias/vite.config.js b/playground/ssr-alias/vite.config.js new file mode 100644 index 00000000000000..391113604fe25c --- /dev/null +++ b/playground/ssr-alias/vite.config.js @@ -0,0 +1,14 @@ +import { defineConfig } from 'vite' + +export default defineConfig({ + build: { + ssr: '/src/main.js', + }, + resolve: { + alias: { + '@vitejs/test-alias-original': '/src/alias-replaced.js', + '@vitejs/test-alias-non-dep': '/src/alias-replaced.js', + 'node:process': '/src/alias-process.js', + }, + }, +}) From 17feaa00a23dbce68ef43af7bc2ee8117126e6e7 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Mon, 15 Jan 2024 10:02:43 +0900 Subject: [PATCH 4/7] fix: alias builtin --- packages/vite/src/node/plugins/importAnalysis.ts | 4 +++- packages/vite/src/node/ssr/ssrExternal.ts | 4 +--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/vite/src/node/plugins/importAnalysis.ts b/packages/vite/src/node/plugins/importAnalysis.ts index c89d5af76de2e5..49b38bbc00d107 100644 --- a/packages/vite/src/node/plugins/importAnalysis.ts +++ b/packages/vite/src/node/plugins/importAnalysis.ts @@ -64,6 +64,7 @@ import { isCSSRequest, isDirectCSSRequest } from './css' import { browserExternalId } from './resolve' import { serializeDefine } from './define' import { WORKER_FILE_ID } from './worker' +import { getAliasPatternMatcher } from './preAlias' const debug = createDebugger('vite:import-analysis') @@ -177,6 +178,7 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin { const fsUtils = getFsUtils(config) const clientPublicPath = path.posix.join(base, CLIENT_PUBLIC_PATH) const enablePartialAccept = config.experimental?.hmrPartialAccept + const matchAlias = getAliasPatternMatcher(config.resolve.alias) let server: ViteDevServer let _env: string | undefined @@ -494,7 +496,7 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin { return } // skip ssr external - if (ssr) { + if (ssr && !matchAlias(specifier)) { if (shouldExternalizeForSSR(specifier, importer, config)) { return } diff --git a/packages/vite/src/node/ssr/ssrExternal.ts b/packages/vite/src/node/ssr/ssrExternal.ts index 9058a613e760fe..5681e000502a5f 100644 --- a/packages/vite/src/node/ssr/ssrExternal.ts +++ b/packages/vite/src/node/ssr/ssrExternal.ts @@ -9,7 +9,6 @@ import { isBuiltin, } from '../utils' import type { ResolvedConfig } from '..' -import { getAliasPatternMatcher } from '../plugins/preAlias' const debug = createDebugger('vite:ssr-external') @@ -126,14 +125,13 @@ function createIsSsrExternal( const processedIds = new Map() const isConfiguredAsExternal = createIsConfiguredAsSsrExternal(config) - const matchAlias = getAliasPatternMatcher(config.resolve.alias) return (id: string, importer?: string) => { if (processedIds.has(id)) { return processedIds.get(id) } let external = false - if (id[0] !== '.' && !path.isAbsolute(id) && !matchAlias(id)) { + if (id[0] !== '.' && !path.isAbsolute(id)) { external = isBuiltin(id) || isConfiguredAsExternal(id, importer) } processedIds.set(id, external) From c96f935964e46d0e0970c08002daaee898fbf288 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Mon, 15 Jan 2024 10:03:25 +0900 Subject: [PATCH 5/7] chore: revert ssr-deps tests --- .../ssr-deps/__tests__/ssr-deps.spec.ts | 6 ----- playground/ssr-deps/alias/index.js | 1 - playground/ssr-deps/alias/package.json | 9 -------- playground/ssr-deps/package.json | 1 - playground/ssr-deps/server.js | 6 ----- playground/ssr-deps/src/alias-replaced.js | 1 - playground/ssr-deps/src/app.js | 5 ---- pnpm-lock.yaml | 23 +++++++++++-------- 8 files changed, 13 insertions(+), 39 deletions(-) delete mode 100644 playground/ssr-deps/alias/index.js delete mode 100644 playground/ssr-deps/alias/package.json delete mode 100644 playground/ssr-deps/src/alias-replaced.js diff --git a/playground/ssr-deps/__tests__/ssr-deps.spec.ts b/playground/ssr-deps/__tests__/ssr-deps.spec.ts index 30e8166d9bf7bb..c8794ce915dc21 100644 --- a/playground/ssr-deps/__tests__/ssr-deps.spec.ts +++ b/playground/ssr-deps/__tests__/ssr-deps.spec.ts @@ -119,12 +119,6 @@ test('import css library', async () => { expect(await page.textContent('.module-condition')).toMatch('[success]') }) -test('resolve.alias', async () => { - await page.goto(url) - expect(await page.textContent('.alias-no-exist')).toMatch('alias-replaced') - expect(await page.textContent('.alias')).toMatch('alias-replaced') -}) - describe.runIf(isServe)('hmr', () => { test('handle isomorphic module updates', async () => { await page.goto(url) diff --git a/playground/ssr-deps/alias/index.js b/playground/ssr-deps/alias/index.js deleted file mode 100644 index 6c09384100a1c0..00000000000000 --- a/playground/ssr-deps/alias/index.js +++ /dev/null @@ -1 +0,0 @@ -export default 'alias-original' diff --git a/playground/ssr-deps/alias/package.json b/playground/ssr-deps/alias/package.json deleted file mode 100644 index 5c7bfa503e2a21..00000000000000 --- a/playground/ssr-deps/alias/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "@vitejs/test-alias", - "private": true, - "version": "0.0.0", - "exports": { - ".": "./index.js" - }, - "type": "module" -} diff --git a/playground/ssr-deps/package.json b/playground/ssr-deps/package.json index 39f242f30df6cf..e861b9c51815e1 100644 --- a/playground/ssr-deps/package.json +++ b/playground/ssr-deps/package.json @@ -30,7 +30,6 @@ "@vitejs/test-external-entry": "file:./external-entry", "@vitejs/test-linked-no-external": "link:./linked-no-external", "@vitejs/test-pkg-exports": "file:./pkg-exports", - "@vitejs/test-alias": "file:./alias", "@vitejs/test-module-condition": "file:./module-condition" }, "devDependencies": { diff --git a/playground/ssr-deps/server.js b/playground/ssr-deps/server.js index 90fc1a8ad7bedc..05e86a863ea744 100644 --- a/playground/ssr-deps/server.js +++ b/playground/ssr-deps/server.js @@ -34,12 +34,6 @@ export async function createServer(root = process.cwd(), hmrPort) { }, }, appType: 'custom', - resolve: { - alias: { - '@vitejs/test-alias': '/src/alias-replaced.js', - '@vitejs/test-alias-no-exist': '/src/alias-replaced.js', - }, - }, ssr: { noExternal: [ '@vitejs/test-no-external-cjs', diff --git a/playground/ssr-deps/src/alias-replaced.js b/playground/ssr-deps/src/alias-replaced.js deleted file mode 100644 index 6ff1ede37eb867..00000000000000 --- a/playground/ssr-deps/src/alias-replaced.js +++ /dev/null @@ -1 +0,0 @@ -export default 'alias-replaced' diff --git a/playground/ssr-deps/src/app.js b/playground/ssr-deps/src/app.js index b4e775241b09f6..719c6eec7e8205 100644 --- a/playground/ssr-deps/src/app.js +++ b/playground/ssr-deps/src/app.js @@ -16,8 +16,6 @@ import importBuiltinCjs from '@vitejs/test-import-builtin-cjs' import { hello as linkedNoExternal } from '@vitejs/test-linked-no-external' import virtualMessage from '@vitejs/test-pkg-exports/virtual' import moduleConditionMessage from '@vitejs/test-module-condition' -import testAlias from '@vitejs/test-alias' -import testAliasNoExist from '@vitejs/test-alias-no-exist' import '@vitejs/test-css-lib' // This import will set a 'Hello World!" message in the nested-external non-entry dependency @@ -92,9 +90,6 @@ export async function render(url, rootDir) { html += `\n

${moduleConditionMessage}

` - html += `\n

message from alias: ${testAlias}

` - html += `\n

message from alias-no-exist: ${testAliasNoExist}

` - html += `\n

${isomorphicModuleMessage}

` html += `\n

` diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1c4adb4bf41055..0caabcaa6244d6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1228,6 +1228,14 @@ importers: specifier: ^4.18.2 version: 4.18.2 + playground/ssr-alias: + dependencies: + '@vitejs/test-alias-original': + specifier: file:./alias-original + version: file:playground/ssr-alias/alias-original + + playground/ssr-alias/alias-original: {} + playground/ssr-conditions: dependencies: '@vitejs/test-ssr-conditions-external': @@ -1247,9 +1255,6 @@ importers: playground/ssr-deps: dependencies: - '@vitejs/test-alias': - specifier: file:./alias - version: file:playground/ssr-deps/alias '@vitejs/test-css-lib': specifier: file:./css-lib version: file:playground/ssr-deps/css-lib @@ -1321,8 +1326,6 @@ importers: specifier: ^4.18.2 version: 4.18.2 - playground/ssr-deps/alias: {} - playground/ssr-deps/css-lib: {} playground/ssr-deps/define-properties-exports: {} @@ -9846,6 +9849,11 @@ packages: dep-a: file:playground/preload/dep-a dev: true + file:playground/ssr-alias/alias-original: + resolution: {directory: playground/ssr-alias/alias-original, type: directory} + name: '@vitejs/test-alias-original' + dev: false + file:playground/ssr-conditions/external: resolution: {directory: playground/ssr-conditions/external, type: directory} name: '@vitejs/test-ssr-conditions-external' @@ -9856,11 +9864,6 @@ packages: name: '@vitejs/test-ssr-conditions-no-external' dev: false - file:playground/ssr-deps/alias: - resolution: {directory: playground/ssr-deps/alias, type: directory} - name: '@vitejs/test-alias' - dev: false - file:playground/ssr-deps/css-lib: resolution: {directory: playground/ssr-deps/css-lib, type: directory} name: '@vitejs/test-css-lib' From c76fcb96328e91865d41f48595e26a2f75862a37 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Mon, 15 Jan 2024 10:17:56 +0900 Subject: [PATCH 6/7] chore: lint --- playground/ssr-alias/src/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playground/ssr-alias/src/main.js b/playground/ssr-alias/src/main.js index 957cd605ef6ba2..14ded7d14b17ff 100644 --- a/playground/ssr-alias/src/main.js +++ b/playground/ssr-alias/src/main.js @@ -1,6 +1,6 @@ +import process from 'node:process' import dep from '@vitejs/test-alias-original' import nonDep from '@vitejs/test-alias-non-dep' -import process from 'node:process' export default { dep, From f99768f7a76d2122d3ba59d85dd7a7eab4f0b429 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Mon, 15 Jan 2024 10:22:06 +0900 Subject: [PATCH 7/7] test: windows unhappy? --- playground/ssr-alias/vite.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playground/ssr-alias/vite.config.js b/playground/ssr-alias/vite.config.js index 391113604fe25c..deb71aee5714a9 100644 --- a/playground/ssr-alias/vite.config.js +++ b/playground/ssr-alias/vite.config.js @@ -2,7 +2,7 @@ import { defineConfig } from 'vite' export default defineConfig({ build: { - ssr: '/src/main.js', + ssr: './src/main.js', }, resolve: { alias: {