Skip to content
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

feat: log compile stats #503

Merged
merged 12 commits into from Nov 22, 2022
Merged

feat: log compile stats #503

merged 12 commits into from Nov 22, 2022

Conversation

dominikg
Copy link
Member

@dominikg dominikg commented Nov 20, 2022

We want to set prebundleSvelteLibraries: true by default and this has implications for users.

Esp. with large component libraries it can lead to significant delays when loading the dev page in the browser or building.
To make these transparent, we collect compile time statistics and log them.

example output for dev:


  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
5:43:05 PM [vite-plugin-svelte] prebundle libraries in progress ...
5:43:19 PM [vite-plugin-svelte] ssr compile in progress ...
5:43:24 PM [vite-plugin-svelte] prebundle libraries done.
package                         files     time     avg
carbon-icons-svelte              2002   10.02s   5.0ms
carbon-components-svelte          206    2.42s  11.7ms
5:43:28 PM [vite-plugin-svelte] ssr compile done.
package                                 files    time     avg
carbon-icons-svelte                      2002   2.68s   1.3ms
carbon-components-svelte                  206   0.53s   2.6ms
playground-big-component-library-kit        3   9.0ms   3.0ms

example output for build:

> vite build

vite v3.2.3 building for production...
✓ 2333 modules transformed.
5:44:47 PM [vite-plugin-svelte] dom compile done.
package                                 files     time     avg
carbon-icons-svelte                      2002    9.02s   4.5ms
carbon-components-svelte                  206    2.27s  11.0ms
playground-big-component-library-kit        4   84.6ms  21.1ms
@sveltejs/kit                               1   22.0ms  22.0ms
vite v3.2.3 building SSR bundle for production...
✓ 2351 modules transformed.
5:44:55 PM [vite-plugin-svelte] ssr compile done.
package                                 files    time     avg
carbon-icons-svelte                      2002   2.96s   1.5ms
carbon-components-svelte                  206   0.59s   2.9ms
playground-big-component-library-kit        4   8.6ms   2.1ms
@sveltejs/kit                               1   1.9ms   1.9ms

These stats are logged at the info level.

You can disable them via the new experimental.disableCompileStats option for vite-plugin-svelte

// svelte.config.js
export default {
  vitePlugin: {
    experimental: {
      disableCompileStats: true, // true disables completely, 'dev' for dev and 'build' for build
    }
  }
}

@dominikg
Copy link
Member Author

added an option to disable because --logLevel warn doesn't seem to propagate to the second vite build kit kicks off and it also removes other useful logging.

Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

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

Moving the option to experimental sounds fine to me 👍 I hope we can start reducing the options for v2 though so there's less to document and nicer ootb experience.

@dominikg dominikg merged commit 079a7b8 into main Nov 22, 2022
@dominikg dominikg deleted the feat/log-stats branch November 22, 2022 08:11
@github-actions github-actions bot mentioned this pull request Nov 22, 2022
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.

None yet

3 participants