Skip to content

Commit

Permalink
Update packages/next/build/swc/jest.js
Browse files Browse the repository at this point in the history
Co-authored-by: JJ Kasper <jj@jjsweb.site>
  • Loading branch information
padmaia and ijjk committed Nov 5, 2021
1 parent f0d9418 commit 867c3a0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/next/build/swc/jest.js
Expand Up @@ -34,19 +34,19 @@ const { transformSync } = require('./index')
/**
* Loads closest package.json in the directory hierarchy
*/
function loadClosesPackageJson(attempts = 1) {
function loadClosestPackageJson(attempts = 1) {
if (attempts > 5) {
throw new Error("Can't resolve main package.json file")
}
var mainPath = attempts === 1 ? './' : Array(attempts).join('../')
try {
return require(mainPath + 'package.json')
} catch (e) {
return loadClosesPackageJson(attempts + 1)
return loadClosestPackageJson(attempts + 1)
}
}

const packageConfig = loadClosesPackageJson()
const packageConfig = loadClosestPackageJson()
const isEsmProject = packageConfig.type === 'module'

// Jest use the `vm` [Module API](https://nodejs.org/api/vm.html#vm_class_vm_module) for ESM.
Expand Down

0 comments on commit 867c3a0

Please sign in to comment.