Skip to content

Commit 5fce63a

Browse files
- Added replacer for Mui
1 parent 0113a44 commit 5fce63a

File tree

5 files changed

+39
-1
lines changed

5 files changed

+39
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,5 @@ out/
141141
# typescript tsbuildinfo
142142
*.tsbuildinfo
143143
lodashReplacer.js
144+
muiReplacer.js
144145

packages/mui/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"src"
1717
],
1818
"scripts": {
19-
"build:ts": "tsc -b tsconfig.build.json && tsc-alias -p tsconfig.build.json",
19+
"compileReplacer": "tsc -p tsconfig.replacer.json",
20+
"build:ts": "npm run compileReplacer && rimraf ./lib && tsc -b tsconfig.build.json && tsc-alias -p tsconfig.build.json",
2021
"build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.js --sourcemap --packages=external --format=cjs",
2122
"build:esm": "esbuild ./src/index.ts --bundle --outfile=dist/mui.esm.js --sourcemap --packages=external --format=esm",
2223
"build:umd": "rollup dist/mui.esm.js --format=umd --file=dist/mui.umd.js --name=@rjsf/mui",

packages/mui/tsconfig.build.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,11 @@
1212
"tsc-alias": {
1313
"resolveFullPaths": true,
1414
"verbose": true,
15+
"replacers": {
16+
"lodash": {
17+
"enabled": true,
18+
"file": "muiReplacer.js"
19+
}
20+
}
1521
}
1622
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"compilerOptions": {
3+
"module": "commonjs",
4+
"target": "es2017",
5+
"outDir": "./",
6+
"skipLibCheck": true,
7+
},
8+
"files": [
9+
"../../tsc-alias-replacer/muiReplacer.ts"
10+
],
11+
"exclude": [
12+
"./src",
13+
"./test"
14+
]
15+
}

tsc-alias-replacer/muiReplacer.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { AliasReplacerArguments } from 'tsc-alias';
2+
3+
/** A `tsc-alias` replacer that fixes up the imports `from 'lodash/xxxx'` to be `from `lodash/xxxx.js`
4+
*
5+
* @param orig - The original import name
6+
*/
7+
export default function exampleReplacer({ orig }: AliasReplacerArguments): string {
8+
if (orig.startsWith("from '@mui/material/")) {
9+
const origMinusEndQuote = orig.substring(0, orig.length - 1);
10+
// console.log(origMinusEndQuote);
11+
return `${origMinusEndQuote}/index.js'`;
12+
}
13+
14+
return orig;
15+
}

0 commit comments

Comments
 (0)