Skip to content

docs: added export size in FunctionInfo #2082

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

Merged
merged 3 commits into from
Aug 15, 2022

Conversation

stephenjason89
Copy link
Contributor

Description

Added export size information inside FunctionInfo

What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • [✓] Documentation update
  • Other

@stephenjason89 stephenjason89 mentioned this pull request Aug 12, 2022
4 tasks
const info = computed(() => functions.find(i => i.name === props.fn))
const format = (ts: number) => ago(-1, 'day')
const lastUpdated = useTimeAgo(new Date(info.value?.lastUpdated || 0))
const link = computed(() => `/functions\#category=${encodeURIComponent(info.value.category)}`)

axios.get('/export-size.md').then(({ data }) => exportSizeMD.value = data)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably don't want to be fetching this data on each page. Ideally it would work like the other function metadata and be fetched during build time. Maybe instead we can include function size inside of @vueuse/metadata

Copy link
Contributor Author

@stephenjason89 stephenjason89 Aug 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wheatjs Thank you for pointing that out, I placed it in metadata.ts and used fs.readFileSync.

Would you happen to know why the document is not rendering?
I can see that console logging it in metadata shows me the correct data taken from export-size.md

here's the error
image

Copy link
Contributor Author

@stephenjason89 stephenjason89 Aug 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it's because code is being called in server and on client. There's no fs on client.
How do i put a if(process.client) ?
process here doesn't have server or client prop

haha I am not sure how to do this.
Please help :D

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to create a json file together with the export-size.md
but everytime i run pnpm size

image

I get this error.

Copy link
Member

@antfu antfu Aug 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to run build first and then analyse the size

Copy link
Member

@antfu antfu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. We should update scripts/export-size.ts to generate a JSON format report, instead of reading the markdown file.
  2. This shouldn't be part of @vueuse/metadata but could be a doc-only json.

@stephenjason89
Copy link
Contributor Author

  1. We should update scripts/export-size.ts to generate a JSON format report, instead of reading the markdown file.
  2. This shouldn't be part of @vueuse/metadata but could be a doc-only json.

Hello @antfu, let me know if I still need to change something.

@antfu
Copy link
Member

antfu commented Aug 15, 2022

Looks good. Thanks.

@antfu antfu merged commit f1bb50c into vueuse:main Aug 15, 2022
@stephenjason89 stephenjason89 deleted the docs/export-size branch August 15, 2022 04:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy