Skip to content

Commit

Permalink
Update CSB preview to use the dev packages
Browse files Browse the repository at this point in the history
  • Loading branch information
michaldudak committed Mar 15, 2024
1 parent 472737f commit f13f363
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 35 deletions.
18 changes: 8 additions & 10 deletions docs/src/modules/sandbox/Dependencies.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import SandboxDependencies from './Dependencies';

describe('Dependencies', () => {
before(() => {
process.env.SOURCE_CODE_REPO = 'https://github.com/mui/material-ui';
process.env.SOURCE_CODE_REPO = 'https://github.com/mui/base-ui';
});

after(() => {
Expand Down Expand Up @@ -167,7 +167,6 @@ import 'exceljs';
'react-dom': 'latest',
'@emotion/react': 'latest',
'@emotion/styled': 'latest',
'@mui/material': 'latest',
'@types/react-dom': 'latest',
'@types/react': 'latest',
typescript: 'latest',
Expand Down Expand Up @@ -244,14 +243,13 @@ import * as Utils from '@mui/utils';
'react-dom': 'latest',
'@emotion/react': 'latest',
'@emotion/styled': 'latest',
'@mui/material': 'https://pkg.csb.dev/mui/material-ui/commit/2d0e8b4d/@mui/material',
'@mui/icons-material':
'https://pkg.csb.dev/mui/material-ui/commit/2d0e8b4d/@mui/icons-material',
'@mui/lab': 'https://pkg.csb.dev/mui/material-ui/commit/2d0e8b4d/@mui/lab',
'@mui/styles': 'https://pkg.csb.dev/mui/material-ui/commit/2d0e8b4d/@mui/styles',
'@mui/system': 'https://pkg.csb.dev/mui/material-ui/commit/2d0e8b4d/@mui/system',
'@mui/utils': 'https://pkg.csb.dev/mui/material-ui/commit/2d0e8b4d/@mui/utils',
'@mui/base': 'https://pkg.csb.dev/mui/material-ui/commit/2d0e8b4d/@mui/base',
'@mui/material': 'latest',
'@mui/icons-material': 'latest',
'@mui/lab': 'latest',
'@mui/styles': 'latest',
'@mui/system': 'latest',
'@mui/utils': 'latest',
'@mui/base': 'https://pkg.csb.dev/mui/base-ui/commit/2d0e8b4d/@mui/base',
});
});

Expand Down
29 changes: 4 additions & 25 deletions docs/src/modules/sandbox/Dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ export default function SandboxDependencies(
function getMuiPackageVersion(packageName: string): string {
if (
commitRef === undefined ||
process.env.SOURCE_CODE_REPO !== 'https://github.com/mui/material-ui'
process.env.SOURCE_CODE_REPO !== 'https://github.com/mui/base-ui'
) {
// #default-branch-switch
return 'latest';
}
const shortSha = commitRef.slice(0, 8);
return `https://pkg.csb.dev/mui/material-ui/commit/${shortSha}/@mui/${packageName}`;
return `https://pkg.csb.dev/mui/base-ui/commit/${shortSha}/@mui/${packageName}`;
}

function extractDependencies(raw: string) {
Expand All @@ -71,11 +71,11 @@ export default function SandboxDependencies(
};

if (newDeps['@mui/lab'] || newDeps['@mui/icons-material']) {
newDeps['@mui/material'] = versions['@mui/material'];
newDeps['@mui/material'] = 'latest';
}

if (newDeps['@mui/x-data-grid']) {
newDeps['@mui/material'] = versions['@mui/material'];
newDeps['@mui/material'] = 'latest';
}

// TODO: consider if this configuration could be injected in a "cleaner" way.
Expand All @@ -93,19 +93,7 @@ export default function SandboxDependencies(
'react-dom': 'latest',
'@emotion/react': 'latest',
'@emotion/styled': 'latest',
'@mui/material': getMuiPackageVersion('material'),
'@mui/icons-material': getMuiPackageVersion('icons-material'),
'@mui/lab': getMuiPackageVersion('lab'),
'@mui/styled-engine': getMuiPackageVersion('styled-engine'),
'@mui/styles': getMuiPackageVersion('styles'),
'@mui/system': getMuiPackageVersion('system'),
'@mui/private-theming': getMuiPackageVersion('theming'),
'@mui/private-classnames': getMuiPackageVersion('classnames'),
'@mui/base': getMuiPackageVersion('base'),
'@mui/utils': getMuiPackageVersion('utils'),
'@mui/material-next': getMuiPackageVersion('material-next'),
'@mui/material-nextjs': getMuiPackageVersion('material-nextjs'),
'@mui/joy': getMuiPackageVersion('joy'),
};

// TODO: consider if this configuration could be injected in a "cleaner" way.
Expand Down Expand Up @@ -146,15 +134,6 @@ export default function SandboxDependencies(
dependencies.typescript = 'latest';
}

if (!demo.productId && !dependencies['@mui/material']) {
// The `index.js` imports StyledEngineProvider from '@mui/material', so we need to make sure we have it as a dependency
const name = '@mui/material';
const versions = {
[name]: getMuiPackageVersion('material'),
};
dependencies[name] = versions[name] ? versions[name] : 'latest';
}

const devDependencies = {
'react-scripts': 'latest',
};
Expand Down

0 comments on commit f13f363

Please sign in to comment.