Skip to content

Commit

Permalink
prettier & copy module.css in built output
Browse files Browse the repository at this point in the history
  • Loading branch information
mnajdova committed Nov 14, 2024
1 parent c36cdc9 commit 9102b08
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 21 deletions.
5 changes: 4 additions & 1 deletion docs/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ export default withDocsInfra({
'@mui/icons-material': path.resolve(workspaceRoot, 'packages/mui-icons-material/lib/esm'),
'@mui/lab': path.resolve(workspaceRoot, 'packages/mui-lab/src'),
'@mui/styled-engine': path.resolve(workspaceRoot, 'packages/mui-styled-engine/src'),
'@mui/styled-engine-noop': path.resolve(workspaceRoot, 'packages/mui-styled-engine-noop/src'),
'@mui/styled-engine-noop': path.resolve(
workspaceRoot,
'packages/mui-styled-engine-noop/src',
),
'@mui/styles': path.resolve(workspaceRoot, 'packages/mui-styles/src'),
'@mui/system': path.resolve(workspaceRoot, 'packages/mui-system/src'),
'@mui/private-theming': path.resolve(workspaceRoot, 'packages/mui-private-theming/src'),
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-material/src/Header/Header.module.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.root {
color: blue;
}
}
2 changes: 1 addition & 1 deletion packages/mui-material/src/Header/Header.module.css.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const root: string;
export const root: string;
6 changes: 4 additions & 2 deletions packages/mui-material/src/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import classes from './Header.module.css';
const HeaderRoot = styled('h1')({});

function Header(props: React.ComponentPropsWithRef<'h1'>) {
return <HeaderRoot {...props} className={clsx('MuiHeader-root', classes.root, props.className)} />;
return (
<HeaderRoot {...props} className={clsx('MuiHeader-root', classes.root, props.className)} />
);
}

export default Header;
export default Header;
2 changes: 1 addition & 1 deletion packages/mui-material/src/Header/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './Header';
export { default } from './Header';
export { default } from './Header';
6 changes: 2 additions & 4 deletions packages/mui-styled-engine-noop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,8 @@
"chai": "^4.5.0",
"react": "^18.3.1"
},
"peerDependencies": {
},
"peerDependenciesMeta": {
},
"peerDependencies": {},
"peerDependenciesMeta": {},
"sideEffects": false,
"publishConfig": {
"access": "public",
Expand Down
15 changes: 6 additions & 9 deletions packages/mui-styled-engine-noop/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ export { default as GlobalStyles } from './GlobalStyles';
export * from './GlobalStyles';

export declare const ThemeContext: React.Context<null>;
export function keyframes(arg:any): string;
export function css(arg:any): string;
export function keyframes(arg: any): string;
export function css(arg: any): string;

/**
* For internal usage in `@mui/system` package
Expand Down Expand Up @@ -47,11 +47,8 @@ export interface CSSObject {}
export type Interpolation = any;

export interface CreateMUIStyled<A extends any, B extends any, C extends any> {
<
C extends any,
ForwardedProps extends any,
>(
component: C,
options: object,
): React.ComponentType<ForwardedProps & A & B & C>;
<C extends any, ForwardedProps extends any>(
component: C,
options: object,
): React.ComponentType<ForwardedProps & A & B & C>;
}
3 changes: 1 addition & 2 deletions packages/mui-styled-engine-noop/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ export function css() {
export const ThemeContext = React.createContext(null);

// eslint-disable-next-line @typescript-eslint/naming-convention
export function internal_mutateStyles(tag, processor) {
}
export function internal_mutateStyles(tag, processor) {}

// eslint-disable-next-line @typescript-eslint/naming-convention
export function internal_serializeStyles(styles) {
Expand Down
4 changes: 4 additions & 0 deletions scripts/copyFiles.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import path from 'path';
import {
createModulePackages,
createPackageFile,
cssModulesCopy,
includeFileInBuild,
prepend,
typescriptCopy,
Expand Down Expand Up @@ -42,6 +43,9 @@ async function run() {
// TypeScript
await typescriptCopy({ from: srcPath, to: buildPath });

// CSS modules
await cssModulesCopy({ from: srcPath, to: buildPath });

const packageData = await createPackageFile();

await Promise.all(
Expand Down
11 changes: 11 additions & 0 deletions scripts/copyFilesUtils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,17 @@ export async function typescriptCopy({ from, to }) {
return Promise.all(cmds);
}

export async function cssModulesCopy({ from, to }) {
if (!(await fse.pathExists(to))) {
console.warn(`path ${to} does not exists`);
return [];
}

const files = await glob('**/*.module.css', { cwd: from });
const cmds = files.map((file) => fse.copy(path.resolve(from, file), path.resolve(to, file)));
return Promise.all(cmds);
}

export async function createPackageFile() {
const packageData = await fse.readFile(path.resolve(packagePath, './package.json'), 'utf8');
const { nyc, scripts, devDependencies, workspaces, ...packageDataOther } =
Expand Down

0 comments on commit 9102b08

Please sign in to comment.