Skip to content

Commit

Permalink
Change to inline
Browse files Browse the repository at this point in the history
  • Loading branch information
styfle committed May 26, 2023
1 parent 6a6855c commit 1f11d44
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions packages/next/src/lib/typescript/writeConfigurationDefaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type DesiredCompilerOptionsShape = {

function getDesiredCompilerOptions(
ts: typeof import('typescript'),
userTsConfig: any
userTsConfig?: { compilerOptions?: CompilerOptions }
): DesiredCompilerOptionsShape {
const o: DesiredCompilerOptionsShape = {
// These are suggested values and will be set when not present in the
Expand Down Expand Up @@ -74,18 +74,26 @@ function getDesiredCompilerOptions(
reason: 'to match webpack resolution',
},
resolveJsonModule: { value: true, reason: 'to match webpack resolution' },
...(userTsConfig?.compilerOptions?.verbatimModuleSyntax === true
? undefined
: {
isolatedModules: {
value: true,
reason: 'requirement for SWC / Babel',
},
}),
jsx: {
parsedValue: ts.JsxEmit.Preserve,
value: 'preserve',
reason: 'next.js implements its own optimized jsx transform',
},
}

if (userTsConfig.compilerOptions?.verbatimModuleSyntax !== true) {
if (userTsConfig?.compilerOptions?.verbatimModuleSyntax !== true) {
o.isolatedModules = {
value: true,
reason: 'requirement for SWC / Babel',
};
}
}

return o
Expand All @@ -96,7 +104,7 @@ export function getRequiredConfiguration(
): Partial<import('typescript').CompilerOptions> {
const res: Partial<import('typescript').CompilerOptions> = {}

const desiredCompilerOptions = getDesiredCompilerOptions(ts, {})
const desiredCompilerOptions = getDesiredCompilerOptions(ts)
for (const optionKey of Object.keys(desiredCompilerOptions)) {
const ev = desiredCompilerOptions[optionKey]
if (!('value' in ev)) {
Expand Down

0 comments on commit 1f11d44

Please sign in to comment.