-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Summory option in .build()
#704
Comments
Yes. It's an experiment so I only added it to the CLI. I'm considering just making this the default behavior in all cases and removing the |
Ok thx for answer :). I will just wait some time for this to become the default behaviour ;D |
I wanted to get a sense of what the summary options feels like so I took a screenshot for myself and or others: My only concern is that when using esbuild with Given the you have Millisecond annotations per-file may not make perfect sense with how esbuild works, given it uses concurrency, etc., but you can also measure the differences between processing file A from file B. In my own project (which uses esbuild), output looks like this. Maybe there is some inspiration to be shared? Implementation here:import * as esbuild from "esbuild"
import * as path from "path"
import * as terminal from "../shared/terminal"
import * as types from "./types"
import * as utils from "./utils"
const TERM_WIDTH = 40
function formatMS(ms: number): string {
switch (true) {
case ms < 250:
// 250ms
return `${ms}ms`
default:
// 0.25ms
return `${(ms / 1e3).toFixed(2)}s`
}
}
export function export_(runtime: types.Runtime, meta: types.RouteMeta, start: number): void {
const dur = formatMS(Date.now() - start)
const l1 = runtime.directories.srcPagesDirectory.length
const l2 = runtime.directories.exportDirectory.length
let color = terminal.white
if (meta.routeInfo.type === "dynamic") {
color = terminal.cyan
}
let dimColor = terminal.dim.white
if (meta.routeInfo.type === "dynamic") {
dimColor = terminal.dim.cyan
}
const src = meta.routeInfo.src.slice(l1)
const src_ext = path.extname(src)
const src_name = src.slice(1, -src_ext.length)
const dst = meta.routeInfo.dst.slice(l2)
const dst_ext = path.extname(dst)
const dst_name = dst.slice(1, -dst_ext.length)
const sep = "-".repeat(Math.max(0, TERM_WIDTH - `/${src_name}${src_ext}\x20`.length))
console.log(
`\x20${terminal.dim(utils.timestamp())}\x20\x20` +
`${dimColor("/")}${color(src_name)}${dimColor(src_ext)} ${dimColor(sep)} ${dimColor("/")}${color(dst_name)}${
start === 0 ? "" : ` ${dimColor(`(${dur})`)}`
}`,
)
}
export function serve(args: esbuild.ServeOnRequestArgs): void {
const dur = formatMS(args.timeInMS)
let color = terminal.normal
if (args.status < 200 || args.status >= 300) {
color = terminal.red
}
let dimColor = terminal.dim
if (args.status < 200 || args.status >= 300) {
dimColor = terminal.dim.red
}
let logger = (...args: unknown[]): void => console.log(...args)
if (args.status < 200 || args.status >= 300) {
logger = (...args) => console.error(...args) // eslint-disable-line
}
const path_ = args.path
const path_ext = path.extname(path_)
const path_name = path_.slice(1, -path_ext.length)
const sep = "-".repeat(Math.max(0, TERM_WIDTH - `/${path_name}${path_ext}\x20`.length))
logger(
`\x20${terminal.dim(utils.timestamp())}\x20\x20` +
`${dimColor("/")}${color(path_name)}${dimColor(path_ext)} ${dimColor(sep)} ${color(args.status)} ${dimColor(
`(${dur})`,
)}`,
)
} I recorded my output to provide an example. Also a screenshot since I think GH requires the video be downloaded first? Clicking this apparently downloads the video. retro-1080.movEdit: I now see that |
I'm fine with changing it. People shouldn't be parsing it (e.g. it's truncated over a certain number of entries) so it should only be for humans.
Good to know. Thanks for calling this out. As you can tell I don't use yarn myself. It looks like this only happens with yarn 1 but not with yarn 2? Technically I could just not print the time if the
I don't think there is a number you can assign to each file that would mean something useful. Go has a preemptable task scheduler so just measuring the time difference between the start and the end of a task doesn't mean the task was running for that whole time. And also esbuild is heavily multithreaded so all of the times would add up to much longer than the actual running time, which is misleading IMO. |
I’m on Yarn 1.22 and I always see this footer when running commands such as Yarn’s decorative text gets annoying when you are relying on terminal output for debugging, so I’ve started doing Maybe I should just use General example: Yarn + esbuild example: (I’m on a Mac FWIW)
Anyway, I do think it’s important for your users to understand how fast esbuild is without the need for Somewhat related: Create React App does some interesting profiling when building (i.e. One interesting direction you could take this is emitting some kind of stats file (a little like your metafile idea, but for bundle statistics / performance metrics). One way I’ve done this in the past (not related to esbuild) is by running a small script on build so every release includes some metadata. If you were to support something like this for esbuild with normal builds (maybe a Sorry for getting off-topic. I just think terminal UIs are generally under-appreciated but is actually critical to adopting new users. |
Hi, I wanted to create multiple scripts for esbuild so it easier to maintain configuration instead of strings in package.json.
Example:
Sadly when I use the
summary
feature in config I receive an error in the terminal:Is
--summary
only available in CLI?The text was updated successfully, but these errors were encountered: