Skip to content
Open
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 packages/x-scheduler-premium/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
},
"homepage": "https://mui.com/x/react-scheduler/",
"exports": {
".": "./src/index.ts",
"./agenda-view-premium": "./src/agenda-view-premium/index.ts",
"./day-view-premium": "./src/day-view-premium/index.ts",
"./event-calendar-premium": "./src/event-calendar-premium/index.ts",
Expand Down
4 changes: 2 additions & 2 deletions packages/x-scheduler-premium/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// This file is used by the docs tooling to discover exported components.
// The package's public API uses sub-path exports defined in package.json.
// This file is the package's root entrypoint (the `.` export in package.json)
// and is also used by the docs tooling to discover exported components.
export * from './agenda-view-premium';
export * from './day-view-premium';
export * from './event-calendar-premium';
Expand Down
1 change: 1 addition & 0 deletions packages/x-scheduler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"url": "https://opencollective.com/mui-org"
},
"exports": {
".": "./src/index.ts",
"./agenda-view": "./src/agenda-view/index.ts",
"./day-view": "./src/day-view/index.ts",
"./event-calendar": "./src/event-calendar/index.ts",
Expand Down
4 changes: 2 additions & 2 deletions packages/x-scheduler/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// This file is used by the docs tooling to discover exported components.
// The package's public API uses sub-path exports defined in package.json.
// This file is the package's root entrypoint (the `.` export in package.json)
// and is also used by the docs tooling to discover exported components.
export * from './agenda-view';
export * from './day-view';
export * from './event-calendar';
Expand Down
27 changes: 27 additions & 0 deletions test/bundle-size/bundle-size-checker.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*
* This file determines which packages and components will have their bundle sizes measured.
*/
import fs from 'fs';
import path from 'path';
import { globby } from 'globby';
import { defineConfig } from '@mui/internal-bundle-size-checker';
Expand All @@ -20,6 +21,28 @@ async function findComponents(packageFolder, packageName) {
return pkgComponents;
}

// Sub-path exports that aren't renderable components and therefore shouldn't be
// tracked individually for bundle size (types, locales, augmentations, internals).
const NON_COMPONENT_EXPORTS = new Set(['models', 'locales', 'theme-augmentation', 'internals']);

/**
* Lists the component entrypoints of a package from its `exports` field.
*
* Unlike `findComponents`, which scans the build output for PascalCase component
* folders, this reads the explicit kebab-case sub-path exports used by the
* scheduler packages, so newly added views are tracked automatically without
* hardcoding them here.
*/
function findComponentsFromExports(packageFolder, packageName) {
const pkgJsonPath = path.join(rootDir, `packages/${packageFolder}/package.json`);
const { exports: pkgExports } = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8'));
return Object.keys(pkgExports)
.filter((key) => key.startsWith('./'))
.map((key) => key.slice(2))
.filter((name) => !NON_COMPONENT_EXPORTS.has(name) && !name.startsWith('use-'))
.map((name) => `${packageName}/${name}`);
}

/**
* Generates the entrypoints configuration by scanning the project structure.
*/
Expand Down Expand Up @@ -71,6 +94,10 @@ export default defineConfig(async () => {
...treeViewComponents,
'@mui/x-tree-view-pro',
...treeViewProComponents,
'@mui/x-scheduler',
...findComponentsFromExports('x-scheduler', '@mui/x-scheduler'),
'@mui/x-scheduler-premium',
...findComponentsFromExports('x-scheduler-premium', '@mui/x-scheduler-premium'),
'@mui/x-license',
'@mui/x-license/internals',
],
Expand Down
Loading