Commit 62fce6f5 authored by Maël Nison's avatar Maël Nison Committed by Tim Neutkens

TS / PnP compatibility (#8744)

* Fixes PnP + TS support

* Uses import on the resolved TS path (since it's not a dep)

* Fixes TS
parent ebb39f10
......@@ -786,17 +786,19 @@ export default async function getBaseWebpackConfig(
}),
!isServer &&
useTypeScript &&
new ForkTsCheckerWebpackPlugin({
typescript: typeScriptPath,
async: dev,
useTypescriptIncrementalApi: true,
checkSyntacticErrors: true,
tsconfig: tsConfigPath,
reportFiles: ['**', '!**/__tests__/**', '!**/?(*.)(spec|test).*'],
compilerOptions: { isolatedModules: true, noEmit: true },
silent: true,
formatter: 'codeframe',
}),
new ForkTsCheckerWebpackPlugin(
PnpWebpackPlugin.forkTsCheckerOptions({
typescript: typeScriptPath,
async: dev,
useTypescriptIncrementalApi: true,
checkSyntacticErrors: true,
tsconfig: tsConfigPath,
reportFiles: ['**', '!**/__tests__/**', '!**/?(*.)(spec|test).*'],
compilerOptions: { isolatedModules: true, noEmit: true },
silent: true,
formatter: 'codeframe',
})
),
config.experimental.modern &&
!isServer &&
!dev &&
......
......@@ -41,16 +41,18 @@ async function checkDependencies({
{ file: '@types/node/index.d.ts', pkg: '@types/node' },
]
let resolutions = new Map<string, string>()
const missingPackages = requiredPackages.filter(p => {
try {
resolveRequest(p.file, `${dir}/`)
resolutions.set(p.pkg, resolveRequest(p.file, `${dir}/`))
} catch (_) {
return true
}
})
if (missingPackages.length < 1) {
return
return resolutions.get('typescript')!
}
const packagesHuman = missingPackages
......@@ -116,9 +118,10 @@ export async function verifyTypeScriptSetup(dir: string): Promise<void> {
}
}
await checkDependencies({ dir, isYarn })
const tsPath = await checkDependencies({ dir, isYarn })
// @ts-ignore
const ts = (await import(tsPath)) as typeof import('typescript')
const ts = await import('typescript')
const compilerOptions: any = {
// These are suggested values and will be set when not present in the
// tsconfig.json
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment