Skip to content

Commit

Permalink
Merge branch 'canary' into patch-3
Browse files Browse the repository at this point in the history
  • Loading branch information
leerob committed Oct 7, 2023
2 parents 16479b2 + 50dff93 commit c0a5d6e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
4 changes: 3 additions & 1 deletion packages/next/src/server/dev/log-app-dir-error.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import isError from '../../lib/is-error'
import * as Log from '../../build/output/log'

export function logAppDirError(err: any) {
export function logAppDirError(err: unknown) {
if (isError(err) && err?.stack) {
const cleanedStack = err.stack.split('\n').map((line: string) =>
// Remove 'webpack-internal:' noise from the path
Expand All @@ -24,6 +24,8 @@ export function logAppDirError(err: any) {
if (typeof (err as any).digest !== 'undefined') {
console.error(`digest: ${JSON.stringify((err as any).digest)}`)
}

if (err.cause) console.error('Cause:', err.cause)
} else {
Log.error(err)
}
Expand Down
39 changes: 22 additions & 17 deletions packages/next/taskfile-webpack.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,40 @@
const webpack = require('webpack')

module.exports = function (task) {
// eslint-disable-next-line require-yield
task.plugin('webpack', {}, function* (_, options) {
options = options || {}

const compiler = webpack(options.config)

if (options.watch) {
compiler.watch({}, (err, stats) => {
return compiler.watch({}, (err, stats) => {
if (err || stats.hasErrors()) {
console.error(err || stats.toString())
} else {
console.log(`${options.name} compiled successfully.`)
}
})
} else {
yield new Promise((resolve, reject) => {
compiler.run((err, stats) => {
if (err || stats.hasErrors()) {
console.error(err || stats.toString())
reject(err || stats.toString())
}
if (process.env.ANALYZE) {
require('fs').writeFileSync(
require('path').join(__dirname, options.name + '-stats.json'),
JSON.stringify(stats.toJson())
)
}
resolve()
})
})
}

return new Promise((resolve) => {
compiler.run((err, stats) => {
if (err || stats.hasErrors()) {
return this.emit('plugin_error', {
plugin: 'taskfile-webpack',
error: err?.message ?? stats.toString(),
})
}

if (process.env.ANALYZE) {
require('fs').writeFileSync(
require('path').join(__dirname, options.name + '-stats.json'),
JSON.stringify(stats.toJson())
)
}

resolve()
})
})
})
}

0 comments on commit c0a5d6e

Please sign in to comment.