Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: build typings #16

Closed
Closed
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: 1 addition & 1 deletion packages/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"esbuild": "^0.19.3",
"postcss": "^8.4.31",
"rollup": "^4.2.0",
"@rolldown/node": "/Users/likui/Github/rolldown/packages/node"
"@rolldown/node": "/Users/likui/Github/rolldown/packages/rolldown"
},
"optionalDependencies": {
"fsevents": "~2.3.3"
Expand Down
8 changes: 3 additions & 5 deletions packages/vite/src/node/optimizer/esbuildDepPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import path from 'node:path'
import type { ImportKind } from 'esbuild'
import type { Plugin } from '@rolldown/node'
import type { Plugin, ImportKind } from '@rolldown/node'
import { KNOWN_ASSET_TYPES } from '../constants'
import type { PackageCache } from '../packages'
import { getDepOptimizationConfig } from '../config'
Expand Down Expand Up @@ -148,8 +147,7 @@ export function rolldownDepPlugin(
cjsPackageCache.clear()
},
resolveId: async function (id, importer, options) {
// TODO rolldown: kind is not available in rollup
const kind: ImportKind = options.kind
const kind = options.kind
// externalize assets and commonly known non-js file types
// See #8459 for more details about this require-import conversion
if (allExternalTypesReg.test(id)) {
Expand Down Expand Up @@ -297,7 +295,7 @@ export function rolldownCjsExternalPlugin(

if (filter.test(id)) {
// TODO rolldown: kind is not available in rollup
const kind: ImportKind = options.kind
const kind = options.kind
if (kind === 'require-call' && platform !== 'node') {
return {
id: cjsExternalFacadeNamespace + id,
Expand Down
26 changes: 2 additions & 24 deletions packages/vite/src/node/optimizer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import type { RollupOptions, RollupOutput } from '@rolldown/node'
import * as rolldown from '@rolldown/node'
import colors from 'picocolors'
import type { BuildOptions as EsbuildBuildOptions, Loader } from 'esbuild'
import { build } from 'esbuild'
import { init, parse } from 'es-module-lexer'
import glob from 'fast-glob'
import { createFilter } from '@rollup/pluginutils'
Expand Down Expand Up @@ -1082,29 +1081,6 @@ function stringifyDepsOptimizerMetadata(
)
}

function esbuildOutputFromId(
outputs: Record<string, any>,
id: string,
cacheDirOutputPath: string,
): any {
const cwd = process.cwd()
const flatId = flattenId(id) + '.js'
const normalizedOutputPath = normalizePath(
path.relative(cwd, path.join(cacheDirOutputPath, flatId)),
)
const output = outputs[normalizedOutputPath]
if (output) {
return output
}
// If the root dir was symlinked, esbuild could return output keys as `../cwd/`
// Normalize keys to support this case too
for (const [key, value] of Object.entries(outputs)) {
if (normalizePath(path.relative(cwd, key)) === normalizedOutputPath) {
return value
}
}
}

export async function extractExportsData(
filePath: string,
config: ResolvedConfig,
Expand Down Expand Up @@ -1240,6 +1216,8 @@ export function getDepHash(config: ResolvedConfig, ssr: boolean): string {
exclude: optimizeDeps?.exclude,
rollupOptions: {
...optimizeDeps?.rollupOptions,
// TODO(underfin): the rollupOptions.plugins how to exclude `ParallelPlugin`
// @ts-ignore
plugins: optimizeDeps?.rollupOptions?.plugins?.map((p) => p.name),
},
},
Expand Down
Loading
Loading