Skip to content

Commit

Permalink
update and configure size-limit
Browse files Browse the repository at this point in the history
  • Loading branch information
etrepum committed Apr 10, 2024
1 parent 861e357 commit 59757ca
Show file tree
Hide file tree
Showing 3 changed files with 1,514 additions and 1,165 deletions.
45 changes: 45 additions & 0 deletions .size-limit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
'use strict';
const glob = require('glob');
const path = require('node:path');
const fs = require('fs-extra');

const alias = Object.fromEntries(
glob('./packages/*/package.json', {sync: true}).flatMap((fn) => {
const pkg = fs.readJsonSync(fn);
if (!pkg.private) {
return Object.entries(pkg.exports).flatMap(([k, v]) => {
if (k.endsWith('.js')) {
return [];
}
return [
[
`${pkg.name}${k.replace(/^\.(\/$)?/, '')}`,
path.resolve(path.dirname(fn), 'dist', v.require.default),
],
];
});
}
return [];
}),
);

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

function sizeLimitConfig(pkg) {
return {
path: alias[pkg],
modifyWebpackConfig,
};
}

module.exports = ['lexical', '@lexical/rich-text', '@lexical/plain-text'].map(
sizeLimitConfig,
);
Loading

0 comments on commit 59757ca

Please sign in to comment.