Skip to content

Commit

Permalink
Limit page size tracking to non-breaking
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Jul 19, 2019
1 parent 5c202eb commit b36c39d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
9 changes: 1 addition & 8 deletions scripts/sizeSnapshot/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,10 @@ async function getNextPagesSize() {
});
const pageRegex = /^(?<treeViewPresentation>||)\s*(?<fileType>σ||)\s*(?<pageUrl>[^\s]+)\s*(?<sizeFormatted>[0-9.]+)\s*(?<sizeUnit>\w+)\s*(?<files>\d+)\s*(?<packages>\d+)/gm;

// legacy ids
const pageUrlIdMappings = {
'/': 'docs.landing',
'/_app': 'docs.main',
};

return Array.from(matchAll(consoleOutput, pageRegex), match => {
const { pageUrl, sizeFormatted, sizeUnit, files, packages } = match.groups;

const snapshotId = pageUrlIdMappings[pageUrl] || `docs-${pageUrl}`;

const snapshotId = `docs-${pageUrl}`;
return [
snapshotId,
{
Expand Down
23 changes: 23 additions & 0 deletions scripts/sizeSnapshot/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
const fse = require('fs-extra');
const path = require('path');
const CompressionPlugin = require('compression-webpack-plugin');

const workspaceRoot = path.join(__dirname, '..', '..');

async function getSizeLimitBundles() {
const nextDir = path.join(workspaceRoot, 'docs/.next');
const buildId = await fse.readFile(path.join(nextDir, 'BUILD_ID'), 'utf8');

const dirname = path.join(nextDir, 'static/chunks');
const [main] = (await fse.readdir(dirname)).reduce((result, filename) => {
if (filename.length === 31) {
return [...result, { path: `${dirname}/${filename}` }];
}

return result;
}, []);

return [
{
name: '@material-ui/core/Paper',
Expand Down Expand Up @@ -101,6 +114,16 @@ async function getSizeLimitBundles() {
webpack: true,
path: 'packages/material-ui/build/esm/Portal/index.js',
},
{
name: 'docs.main',
webpack: false,
path: path.relative(workspaceRoot, main.path),
},
{
name: 'docs.landing',
webpack: false,
path: path.relative(workspaceRoot, path.join(nextDir, `static/${buildId}/pages/index.js`)),
},
];
}

Expand Down

0 comments on commit b36c39d

Please sign in to comment.