-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: experimental build analyze (#190)
- v2.1.1
- v2.1.0
- v2.0.0
- v2.0.0-beta.7
- v2.0.0-beta.6
- v2.0.0-beta.5
- v2.0.0-beta.4
- v2.0.0-beta.3
- v2.0.0-beta.2
- v2.0.0-beta.1
- v1.7.0
- v1.6.4
- v1.6.3
- v1.6.2
- v1.6.1
- v1.6.0
- v1.5.2
- v1.5.1
- v1.5.0
- v1.4.2
- v1.4.1
- v1.4.0
- v1.3.14
- v1.3.13
- v1.3.12
- v1.3.11
- v1.3.10
- v1.3.9
- v1.3.8
- v1.3.7
- v1.3.6
- v1.3.5
- v1.3.4
- v1.3.3
- v1.3.2
- v1.3.1
- v1.3.0
- v1.2.0
- v1.1.5
- v1.1.4
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.9
- v1.0.8
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- v1.0.0-beta.3
- v1.0.0-beta.2
- v1.0.0-beta.1
- v1.0.0-beta.0
- v0.8.5
- v0.8.4
- v0.8.3
- v0.8.2
- v0.8.1
- v0.8.0
- v0.7.6
- v0.7.5
- v0.7.4
- v0.7.3
- v0.7.2
- v0.7.1
- v0.7.0
- v0.6.7
- v0.6.6
- v0.6.5
- v0.6.4
- v0.6.3
- v0.6.2
- v0.6.1
- v0.6.0
- v0.5.5
- v0.5.4
- v0.5.3
- v0.5.2
- v0.5.1
- v0.5.0
Showing
21 changed files
with
646 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import type { NuxtAnalyzeMeta } from '@nuxt/schema' | ||
|
||
export interface AnalyzeBuildMeta extends NuxtAnalyzeMeta { | ||
features: { | ||
bundleClient: boolean | ||
bundleNitro: boolean | ||
viteInspect: boolean | ||
} | ||
size: { | ||
clientBundle?: number | ||
nitroBundle?: number | ||
} | ||
} | ||
|
||
export interface AnalyzeBuildsInfo { | ||
isBuilding: boolean | ||
builds: AnalyzeBuildMeta[] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
131 changes: 131 additions & 0 deletions
131
packages/devtools/client/components/BuildAnalyzeDetails.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
<script setup lang="ts"> | ||
import { formatTimeAgo } from '@vueuse/core' | ||
import type { AnalyzeBuildMeta } from '../../src/types' | ||
const props = defineProps<{ | ||
current: AnalyzeBuildMeta | ||
prev?: AnalyzeBuildMeta | ||
}>() | ||
const ROUTE_ANALYZE = '/__nuxt_devtools__/analyze/' | ||
const tabs = computed(() => { | ||
const items = [ | ||
{ name: 'Overview', id: 'overview' }, | ||
] | ||
if (props.current.features.bundleClient) | ||
items.push({ name: 'Client Bundle', id: 'bundle-client' }) | ||
if (props.current.features.bundleNitro) | ||
items.push({ name: 'Nitro Bundle', id: 'bundle-nitro' }) | ||
if (props.current.features.viteInspect) | ||
items.push({ name: 'Vite Inspect', id: 'vite-inspect' }) | ||
return items | ||
}) | ||
const selectedTab = ref(tabs.value[0]) | ||
const openInEditor = useOpenInEditor() | ||
function formatFileSize(bytes: number) { | ||
if (bytes < 1024) | ||
return `${bytes}B` | ||
if (bytes < 1024 * 1024) | ||
return `${(bytes / 1024).toFixed(1)}KB` | ||
if (bytes < 1024 * 1024 * 1024) | ||
return `${(bytes / 1024 / 1024).toFixed(1)}MB` | ||
return `${(bytes / 1024 / 1024 / 1024).toFixed(1)}GB` | ||
} | ||
function formatDuration(build: AnalyzeBuildMeta) { | ||
return `${((build.endTime - build.startTime) / 1000).toFixed(1)}s` | ||
} | ||
</script> | ||
|
||
<template> | ||
<div h-full grid="~ rows-[max-content_1fr]"> | ||
<div flex="~ wrap" w-full> | ||
<template v-for="tab, idx of tabs" :key="idx"> | ||
<button | ||
px4 py2 border="r base" | ||
hover="bg-active" | ||
:class="tab.id === selectedTab.id ? '' : 'border-b'" | ||
@click="selectedTab = tab" | ||
> | ||
<div :class="tab.id === selectedTab.id ? '' : 'op30' "> | ||
{{ tab.name }} | ||
</div> | ||
</button> | ||
</template> | ||
<div border="b base" flex-auto /> | ||
</div> | ||
<div | ||
v-if="selectedTab.id === 'overview'" | ||
flex="~ col gap-4 items-center justify-center" p4 | ||
> | ||
<div flex-auto /> | ||
<div grid="~ cols-[30px_1fr] gap-x-2 gap-y-3 items-center justify-center" w-100> | ||
<div i-carbon-commit text-xl /> | ||
<div> | ||
<div text-sm op50> | ||
Name | ||
</div> | ||
<div>{{ current.name }}</div> | ||
</div> | ||
<div i-carbon-time text-xl /> | ||
<div> | ||
<div text-sm op50> | ||
Build duration | ||
</div> | ||
<div>{{ formatDuration(current) }}</div> | ||
</div> | ||
<template v-if="current.size?.clientBundle"> | ||
<div i-carbon-cics-program text-xl /> | ||
<div> | ||
<div text-sm op50> | ||
Client bundle size | ||
</div> | ||
<div>{{ formatFileSize(current.size.clientBundle) }}</div> | ||
</div> | ||
</template> | ||
<template v-if="current.size.nitroBundle"> | ||
<div i-carbon-bare-metal-server text-xl /> | ||
<div> | ||
<div text-sm op50> | ||
Nitro bundle size | ||
</div> | ||
<div>{{ formatFileSize(current.size.nitroBundle) }}</div> | ||
</div> | ||
</template> | ||
<div i-carbon-edge-node text-xl /> | ||
<div> | ||
<div text-sm op50> | ||
Built | ||
</div> | ||
<div>{{ formatTimeAgo(new Date(current.endTime)) }}</div> | ||
</div> | ||
</div> | ||
<NButton n="primary" icon="carbon-launch" @click="openInEditor(current.analyzeDir)"> | ||
Open in Editor | ||
</NButton> | ||
<div flex-auto /> | ||
<NButton n="rose" icon="carbon-delete" @click="rpc.clearAnalyzeBuilds([current.name])"> | ||
Delete this report | ||
</NButton> | ||
</div> | ||
<iframe | ||
v-lazy-show="selectedTab.id === 'bundle-client'" | ||
:src="`${ROUTE_ANALYZE}${current.slug}/client.html`" | ||
h-full w-full | ||
/> | ||
<iframe | ||
v-lazy-show="selectedTab.id === 'bundle-nitro'" | ||
:src="`${ROUTE_ANALYZE}${current.slug}/nitro.html`" | ||
h-full w-full | ||
/> | ||
<iframe | ||
v-lazy-show="selectedTab.id === 'vite-inspect'" | ||
:src="`${ROUTE_ANALYZE}${current.slug}/.vite-inspect/`" | ||
h-full w-full | ||
/> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.