Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add regenerator path #30786

Merged
merged 2 commits into from
Nov 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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