Skip to content

Commit

Permalink
update undefiend case of ts compiler options
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Feb 16, 2025
1 parent ec0b5d8 commit 500314e
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"@types/clean-css": "^4.2.11",
"@types/node": "^22.9.3",
"@types/picomatch": "^3.0.1",
"@types/react": "19.0.1",
"@types/react": "^19.0.9",
"@types/yargs": "^17.0.33",
"bunchee": "link:./",
"cross-env": "^7.0.3",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

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

2 changes: 1 addition & 1 deletion src/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ async function bundle(

const defaultTsOptions: TypescriptOptions = {
tsConfigPath: tsConfig?.tsConfigPath,
tsCompilerOptions: tsConfig?.tsCompilerOptions || {},
tsCompilerOptions: tsConfig?.tsCompilerOptions,
}

// Handle single entry file
Expand Down
10 changes: 6 additions & 4 deletions src/rollup/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ async function createDtsPlugin(
cwd: string,
) {
const enableIncrementalWithoutBuildInfo =
tsCompilerOptions.incremental && !tsCompilerOptions.tsBuildInfoFile
tsCompilerOptions?.incremental && !tsCompilerOptions?.tsBuildInfoFile
const incrementalOptions = enableIncrementalWithoutBuildInfo
? {
incremental: false,
}
: undefined
const compositeOptions = tsCompilerOptions.composite
const compositeOptions = tsCompilerOptions?.composite
? {
composite: false,
}
Expand All @@ -69,7 +69,7 @@ async function createDtsPlugin(
// resolving types from <reference> from node_modules
preserveSymlinks: false,
target: 'ESNext',
...(!tsCompilerOptions.jsx
...(!tsCompilerOptions?.jsx
? {
jsx: 'react-jsx',
}
Expand Down Expand Up @@ -137,7 +137,9 @@ export async function buildInputConfig(

const { useTypeScript } = buildContext
const { runtime, target: jscTarget, minify: shouldMinify } = bundleConfig
const hasSpecifiedTsTarget = Boolean(tsCompilerOptions.target && tsConfigPath)
const hasSpecifiedTsTarget = Boolean(
tsCompilerOptions?.target && tsConfigPath,
)

const swcParserConfig: import('@swc/types').ParserConfig = {
syntax: useTypeScript ? 'typescript' : 'ecmascript',
Expand Down
2 changes: 1 addition & 1 deletion src/rollup/split-chunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function getModuleLayer(moduleMeta: CustomPluginOptions): string | undefined {

// dependencyGraphMap: Map<subModuleId, Set<entryParentId>>
export function createSplitChunks(
dependencyGraphMap: Map<string, Set<[string, string]>>,
dependencyGraphMap: Map<string, Set<[string, string | undefined]>>,
entryFiles: Set<string>,
): GetManualChunk {
// If there's existing chunk being splitted, and contains a layer { <id>: <chunkGroup> }
Expand Down
2 changes: 1 addition & 1 deletion src/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { logger } from './logger'

export type TypescriptOptions = {
tsConfigPath: string | undefined
tsCompilerOptions: CompilerOptions
tsCompilerOptions: CompilerOptions | undefined
}

let hasLoggedTsWarning = false
Expand Down

0 comments on commit 500314e

Please sign in to comment.