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

[DO NOT MERGE] Provide a standalone way to run rollup for stats gathering #3115

Closed
wants to merge 2 commits into from

Conversation

romaricpascal
Copy link
Member

@romaricpascal romaricpascal commented Dec 16, 2022

Just a late idea for running a more recent version of rollup for gathering stats, waiting for us to move to rollup 3, taking a different route than #3109:

Instead of running during our build, it bundles a one off entry, dynamically generated, that imports the content of our package. rollup-plugin-visualizer still serves as a stat collection tool and we'd need to look in the JSON stats it creates to highlight what we want.

I'm imagining multiple entries pointing to each of the govuk-esm files to ensure that when imported they only load the modules we expect them to. Especially when importing parts of the exports (eg. Accordion from all.mjs), we could check that treeshaking works as intended.

This could be:

  • a route to look into collecting stats with rollup-plugin-visualizer before we set it up on our build. Allowing us to put all the effort on it rather than a bit with size-limit now, and digging deeper once we've moved to rollup 3.
  • a route to check treeshaking output (though it would only be valid for rollup's way of tree-shaking)

How it works

It uses an npm workspace to let us install a newer version of Rollup for our shenanigans. That means you'll need to run it with:

npm start --workspace stats

It then configures rollup with:

Futher development Quick try

Idea would be to generate a list of [filePath, importName?] entries based on a listing of the following format, filing results in files properly namespaced ([componentOrFileName]-[import].json for example:

module.exports =  [
[ 'all.mjs', '*'], // export '*' from 'all.mjs',
['all.mjs', '{Accordion}'], // export {Accordion} from 'all.mjs'
[ 'components/accordion/accordion.mjs], // export 'components/accordion/accordion.mjs
].map(function () {
// Create rollup configuration from each entry
});

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-3115 December 16, 2022 18:18 Inactive
@romaricpascal romaricpascal force-pushed the rollup-plugin-visualiser-standalone branch from e4664bb to 8e160ab Compare December 16, 2022 18:20
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-3115 December 16, 2022 18:20 Inactive
@romaricpascal romaricpascal force-pushed the rollup-plugin-visualiser-standalone branch from 8e160ab to 066a5cd Compare January 9, 2023 16:17
@romaricpascal
Copy link
Member Author

Spike work is complete and perf work carries on in #3279

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.

2 participants