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

[Lexical][Size-Checks] Measure both cjs/esm builds for regression checks #6219

Merged
merged 3 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/tests-extended.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
paths-ignore:
- 'packages/lexical-website/**'
- 'packages/*/README.md'
- '.size-limit.js'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
59 changes: 30 additions & 29 deletions .size-limit.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,47 +32,48 @@ const path = require('node:path');
* as that is what was measured previously in #3600.
*/
const {packagesManager} = require('./scripts/shared/packagesManager');
const alias = Object.fromEntries(
packagesManager
.getPublicPackages()
.flatMap((pkg) =>
pkg
.getNormalizedNpmModuleExportEntries()
.map(([k, v]) => [k, pkg.resolve('dist', v.require.default)]),
),
);
const getAliasType = (type) =>
Sahejkm marked this conversation as resolved.
Show resolved Hide resolved
Object.fromEntries(
packagesManager
.getPublicPackages()
.flatMap((pkg) =>
pkg
.getNormalizedNpmModuleExportEntries()
.map(([k, v]) => [k, pkg.resolve('dist', v[type].default)]),
),
);

const extendConfig = {resolve: {alias}};
const modifyWebpackConfig = (config) => Object.assign(config, extendConfig);
const modifyWebpackConfigForType = (config, alias) =>
Object.assign(config, {resolve: {alias}});

function sizeLimitConfig(pkg) {
return {
path:
alias[pkg] != null
? alias[pkg]
: Object.keys(alias)
.filter((k) => k.startsWith(pkg))
.map((k) => alias[k]),
modifyWebpackConfig,
running: false,
name: pkg,
};
return ['require', 'import'].map((type) => {
const aliasType = getAliasType(type);
return {
path:
aliasType[pkg] != null
? aliasType[pkg]
: Object.keys(aliasType)
.filter((k) => k.startsWith(pkg))
.map((k) => aliasType[k]),
modifyWebpackConfig: (config) =>
modifyWebpackConfigForType(config, aliasType),
running: false,
name: pkg + ' - ' + (type === 'require' ? 'cjs' : 'esm'),
};
});
}

/**
* These are the packages that were measured previously in #3600
* We could consider adding more packages and/or also measuring
* other build combinations such as esbuild/webpack, mjs/cjs, dev/prod, etc.
* other build combinations such as esbuild/webpack.
*
* The current configuration measures only: webpack + cjs + prod.
* The current configuration measures only: webpack + esm/cjs + prod.
*
* In order to also measure dev, we would want to change the size script in
* package.json to run build-release instead of build-prod so both
* dev and prod artifacts would be available.
*/
module.exports = [
'lexical',
'@lexical/rich-text',
'@lexical/plain-text',
'@lexical/react',
].map(sizeLimitConfig);
].flatMap(sizeLimitConfig);
Loading