Unverified Commit 49990f55 authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

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.
parent a1b46817
{
// 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 @@ ...@@ -31,7 +31,8 @@
"publish-canary": "lerna version prerelease --preid canary --force-publish && release --pre", "publish-canary": "lerna version prerelease --preid canary --force-publish && release --pre",
"publish-stable": "lerna version --force-publish", "publish-stable": "lerna version --force-publish",
"lint-staged": "lint-staged", "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", "pre-commit": "lint-staged",
"devDependencies": { "devDependencies": {
......
// taskr babel plugin with Babel 7 support // taskr babel plugin with Babel 7 support
// https://github.com/lukeed/taskr/pull/305 // https://github.com/lukeed/taskr/pull/305
const extname = require('path').extname const path = require('path')
const transform = require('@babel/core').transform const transform = require('@babel/core').transform
const babelClientOpts = { const babelClientOpts = {
...@@ -88,6 +88,10 @@ module.exports = function (task) { ...@@ -88,6 +88,10 @@ module.exports = function (task) {
const babelOpts = const babelOpts =
serverOrClient === 'client' ? babelClientOpts : babelServerOpts 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 = { const options = {
...babelOpts, ...babelOpts,
plugins: [ plugins: [
...@@ -108,11 +112,14 @@ module.exports = function (task) { ...@@ -108,11 +112,14 @@ module.exports = function (task) {
compact: true, compact: true,
babelrc: false, babelrc: false,
configFile: false, configFile: false,
filename: file.base, cwd: __dirname,
filename: path.join(file.dir, file.base),
sourceFileName: path.relative(distFilePath, fullFilePath),
sourceMaps: true, sourceMaps: true,
} }
const output = transform(file.data, options) 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 // Replace `.ts|.tsx` with `.js` in files with an extension
if (ext) { if (ext) {
...@@ -132,6 +139,8 @@ module.exports = function (task) { ...@@ -132,6 +139,8 @@ module.exports = function (task) {
if (output.map) { if (output.map) {
const map = `${file.base}.map` const map = `${file.base}.map`
output.code += Buffer.from(`\n//# sourceMappingURL=${map}`)
// add sourcemap to `files` array // add sourcemap to `files` array
this._.files.push({ this._.files.push({
base: map, base: map,
......
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