Skip to content

Commit

Permalink
[Lexical][Size-Checks] Measure both cjs/esm builds for regression che…
Browse files Browse the repository at this point in the history
…cks (#6219)
  • Loading branch information
Sahejkm authored May 31, 2024
1 parent bbcfd03 commit d14cc07
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 29 deletions.
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) =>
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);

0 comments on commit d14cc07

Please sign in to comment.