Skip to content

Commit

Permalink
Add regenerator path (#30786)
Browse files Browse the repository at this point in the history
  • Loading branch information
timneutkens committed Nov 2, 2021
1 parent e79f788 commit 64e4141
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/next/build/webpack/loaders/next-swc-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ function getSWCOptions({
},
},
},
regenerator: {
importPath: require.resolve('regenerator-runtime'),
},
},
}

Expand Down
12 changes: 12 additions & 0 deletions test/integration/pnpm-support/app/pages/regenerator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { useState, useEffect } from 'react'

export default function RegeneratorTest() {
const [message, setMessage] = useState('')
useEffect(() => {
;(async () => {
await new Promise((resolve) => setTimeout(resolve, 50))
setMessage('Hello World')
})()
}, [])
return <h1>{message}</h1>
}
9 changes: 8 additions & 1 deletion test/integration/pnpm-support/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ const packagesDir = path.join(__dirname, '..', '..', '..', '..', 'packages')
const appDir = path.join(__dirname, '..', 'app')

const runNpm = (cwd, ...args) => execa('npm', [...args], { cwd })
const runPnpm = (cwd, ...args) => execa('npx', ['pnpm', ...args], { cwd })
const runPnpm = async (cwd, ...args) => {
try {
return await execa('npx', ['pnpm', ...args], { cwd })
} catch (err) {
console.error({ err })
throw err
}
}

async function usingTempDir(fn) {
const folder = path.join(os.tmpdir(), Math.random().toString(36).substring(2))
Expand Down

0 comments on commit 64e4141

Please sign in to comment.