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
4 changes: 2 additions & 2 deletions packages/plugin-rsc/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ import { generateEncryptionKey, toBase64 } from './utils/encryption-utils'
import { createRpcServer } from './utils/rpc'
import {
cleanUrl,
evalValue,
normalizeViteImportAnalysisUrl,
prepareError,
} from './vite-utils'
} from './plugins/vite-utils'
import { cjsModuleRunnerPlugin } from './plugins/cjs'
import {
createVirtualPlugin,
evalValue,
getEntrySource,
hashString,
normalizeRelativePath,
Expand Down
15 changes: 0 additions & 15 deletions packages/plugin-rsc/src/plugins/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,6 @@ import {
type Rollup,
} from 'vite'

// https://github.com/vitejs/vite/blob/ea9aed7ebcb7f4be542bd2a384cbcb5a1e7b31bd/packages/vite/src/node/utils.ts#L1469-L1475
export function evalValue<T = any>(rawValue: string): T {
const fn = new Function(`
var console, exports, global, module, process, require
return (\n${rawValue}\n)
`)
return fn()
}

// https://github.com/vitejs/vite/blob/946831f986cb797009b8178659d2b31f570c44ff/packages/vite/src/shared/utils.ts#L31-L34
const postfixRE = /[?#].*$/
export function cleanUrl(url: string): string {
return url.replace(postfixRE, '')
}

export function sortObject<T extends object>(o: T) {
return Object.fromEntries(
Object.entries(o).sort(([a], [b]) => a.localeCompare(b)),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// import analysis logic copied from vite
// misc utilities copied from vite

import fs from 'node:fs'
import path from 'node:path'
Expand Down Expand Up @@ -152,3 +152,12 @@ function cleanStack(stack: string) {
.filter((l) => /^\s*at/.test(l))
.join('\n')
}

// https://github.com/vitejs/vite/blob/ea9aed7ebcb7f4be542bd2a384cbcb5a1e7b31bd/packages/vite/src/node/utils.ts#L1469-L1475
export function evalValue<T = any>(rawValue: string): T {
const fn = new Function(`
var console, exports, global, module, process, require
return (\n${rawValue}\n)
`)
return fn()
}
1 change: 0 additions & 1 deletion packages/plugin-rsc/tsdown.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export default defineConfig({
'src/browser.ts',
'src/ssr.tsx',
'src/rsc.tsx',
'src/vite-utils.ts',
'src/core/browser.ts',
'src/core/ssr.ts',
'src/core/rsc.ts',
Expand Down
Loading