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,7 +786,8 @@ export default async function getBaseWebpackConfig( ...@@ -786,7 +786,8 @@ export default async function getBaseWebpackConfig(
}), }),
!isServer && !isServer &&
useTypeScript && useTypeScript &&
new ForkTsCheckerWebpackPlugin({ new ForkTsCheckerWebpackPlugin(
PnpWebpackPlugin.forkTsCheckerOptions({
typescript: typeScriptPath, typescript: typeScriptPath,
async: dev, async: dev,
useTypescriptIncrementalApi: true, useTypescriptIncrementalApi: true,
...@@ -796,7 +797,8 @@ export default async function getBaseWebpackConfig( ...@@ -796,7 +797,8 @@ export default async function getBaseWebpackConfig(
compilerOptions: { isolatedModules: true, noEmit: true }, compilerOptions: { isolatedModules: true, noEmit: true },
silent: true, silent: true,
formatter: 'codeframe', formatter: 'codeframe',
}), })
),
config.experimental.modern && config.experimental.modern &&
!isServer && !isServer &&
!dev && !dev &&
......
...@@ -41,16 +41,18 @@ async function checkDependencies({ ...@@ -41,16 +41,18 @@ async function checkDependencies({
{ file: '@types/node/index.d.ts', pkg: '@types/node' }, { file: '@types/node/index.d.ts', pkg: '@types/node' },
] ]
let resolutions = new Map<string, string>()
const missingPackages = requiredPackages.filter(p => { const missingPackages = requiredPackages.filter(p => {
try { try {
resolveRequest(p.file, `${dir}/`) resolutions.set(p.pkg, resolveRequest(p.file, `${dir}/`))
} catch (_) { } catch (_) {
return true return true
} }
}) })
if (missingPackages.length < 1) { if (missingPackages.length < 1) {
return return resolutions.get('typescript')!
} }
const packagesHuman = missingPackages const packagesHuman = missingPackages
...@@ -116,9 +118,10 @@ export async function verifyTypeScriptSetup(dir: string): Promise<void> { ...@@ -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 = { const compilerOptions: any = {
// These are suggested values and will be set when not present in the // These are suggested values and will be set when not present in the
// tsconfig.json // 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