Unverified Commit 88fd9a0d authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Update jsconfig paths fix for windows (#12328)

parent c1aeaa48
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
* The TypeScript license can be found here: * The TypeScript license can be found here:
* https://github.com/microsoft/TypeScript/blob/214df64e287804577afa1fea0184c18c40f7d1ca/LICENSE.txt * https://github.com/microsoft/TypeScript/blob/214df64e287804577afa1fea0184c18c40f7d1ca/LICENSE.txt
*/ */
import path from 'path'
import { ResolvePlugin } from 'webpack' import { ResolvePlugin } from 'webpack'
import { join } from 'path'
import { debug } from 'next/dist/compiled/debug' import { debug } from 'next/dist/compiled/debug'
const log = debug('next:jsconfig-paths-plugin') const log = debug('next:jsconfig-paths-plugin')
...@@ -170,7 +170,10 @@ export class JsConfigPathsPlugin implements ResolvePlugin { ...@@ -170,7 +170,10 @@ export class JsConfigPathsPlugin implements ResolvePlugin {
return return
} }
if (moduleName.startsWith('/')) { if (
path.posix.isAbsolute(moduleName) ||
(process.platform === 'win32' && path.win32.isAbsolute(moduleName))
) {
log('skipping request as it is an absolute path %s', moduleName) log('skipping request as it is an absolute path %s', moduleName)
return return
} }
...@@ -199,14 +202,16 @@ export class JsConfigPathsPlugin implements ResolvePlugin { ...@@ -199,14 +202,16 @@ export class JsConfigPathsPlugin implements ResolvePlugin {
let triedPaths = [] let triedPaths = []
for (const subst of paths[matchedPatternText]) { for (const subst of paths[matchedPatternText]) {
const path = matchedStar ? subst.replace('*', matchedStar) : subst const curPath = matchedStar
? subst.replace('*', matchedStar)
: subst
// Ensure .d.ts is not matched // Ensure .d.ts is not matched
if (path.endsWith('.d.ts')) { if (curPath.endsWith('.d.ts')) {
continue continue
} }
const candidate = join(baseDirectory, path) const candidate = path.join(baseDirectory, curPath)
const [err, result] = await new Promise(resolve => { const [err, result] = await new Promise(resolve => {
const obj = Object.assign({}, request, { const obj = Object.assign({}, request, {
request: candidate, request: candidate,
......
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