mirror of
https://github.com/facebook/lexical.git
synced 2025-05-17 15:18:47 +08:00
[Lexical][Size-Checks] Measure both cjs/esm builds for regression checks (#6219)
This commit is contained in:
1
.github/workflows/tests-extended.yml
vendored
1
.github/workflows/tests-extended.yml
vendored
@ -6,6 +6,7 @@ on:
|
||||
paths-ignore:
|
||||
- 'packages/lexical-website/**'
|
||||
- 'packages/*/README.md'
|
||||
- '.size-limit.js'
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user