Add support for debugging Next.js core (#13101)
Note this is only for the Next.js core, will look at a configuration for the debugger for Next.js apps soon.
This commit is contained in:
parent
a1b46817eb
commit
49990f558d
3 changed files with 57 additions and 4 deletions
43
.vscode/launch.json
vendored
Normal file
43
.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Launch app development",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"cwd": "${workspaceFolder}",
|
||||
"runtimeExecutable": "yarn",
|
||||
"runtimeArgs": ["run", "debug", "dev", "test/integration/basic"],
|
||||
"port": 9229
|
||||
},
|
||||
{
|
||||
"name": "Launch app build",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"cwd": "${workspaceFolder}",
|
||||
"runtimeExecutable": "yarn",
|
||||
"runtimeArgs": ["run", "debug", "build", "test/integration/basic"],
|
||||
"port": 9229
|
||||
},
|
||||
{
|
||||
"name": "Launch app production",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"cwd": "${workspaceFolder}",
|
||||
"runtimeExecutable": "yarn",
|
||||
"runtimeArgs": ["run", "debug", "start", "test/integration/basic"],
|
||||
"port": 9229
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "attach",
|
||||
"name": "Attach to existing debugger",
|
||||
"port": 9229,
|
||||
"skipFiles": ["<node_internals>/**"],
|
||||
"outFiles": ["${workspaceFolder}/packages/next/dist/**/*"]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -31,7 +31,8 @@
|
|||
"publish-canary": "lerna version prerelease --preid canary --force-publish && release --pre",
|
||||
"publish-stable": "lerna version --force-publish",
|
||||
"lint-staged": "lint-staged",
|
||||
"next": "node packages/next/dist/bin/next"
|
||||
"next": "node packages/next/dist/bin/next",
|
||||
"debug": "node --inspect-brk packages/next/dist/bin/next"
|
||||
},
|
||||
"pre-commit": "lint-staged",
|
||||
"devDependencies": {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// taskr babel plugin with Babel 7 support
|
||||
// https://github.com/lukeed/taskr/pull/305
|
||||
|
||||
const extname = require('path').extname
|
||||
const path = require('path')
|
||||
const transform = require('@babel/core').transform
|
||||
|
||||
const babelClientOpts = {
|
||||
|
@ -88,6 +88,10 @@ module.exports = function (task) {
|
|||
const babelOpts =
|
||||
serverOrClient === 'client' ? babelClientOpts : babelServerOpts
|
||||
|
||||
const filePath = path.join(file.dir, file.base)
|
||||
const fullFilePath = path.join(__dirname, filePath)
|
||||
const distFilePath = path.dirname(path.join(__dirname, 'dist', filePath))
|
||||
|
||||
const options = {
|
||||
...babelOpts,
|
||||
plugins: [
|
||||
|
@ -108,11 +112,14 @@ module.exports = function (task) {
|
|||
compact: true,
|
||||
babelrc: false,
|
||||
configFile: false,
|
||||
filename: file.base,
|
||||
cwd: __dirname,
|
||||
filename: path.join(file.dir, file.base),
|
||||
sourceFileName: path.relative(distFilePath, fullFilePath),
|
||||
sourceMaps: true,
|
||||
}
|
||||
|
||||
const output = transform(file.data, options)
|
||||
const ext = extname(file.base)
|
||||
const ext = path.extname(file.base)
|
||||
|
||||
// Replace `.ts|.tsx` with `.js` in files with an extension
|
||||
if (ext) {
|
||||
|
@ -132,6 +139,8 @@ module.exports = function (task) {
|
|||
if (output.map) {
|
||||
const map = `${file.base}.map`
|
||||
|
||||
output.code += Buffer.from(`\n//# sourceMappingURL=${map}`)
|
||||
|
||||
// add sourcemap to `files` array
|
||||
this._.files.push({
|
||||
base: map,
|
||||
|
|
Loading…
Reference in a new issue