Skip to content

Commit 2ca9dda

Browse files
committed
material-code esm/cjs: add exports, back to separate esm folder;
but not "strict esm", so no `type: module` in material-code package.json, as long as it needs to support dependencies which do not have this, it can break bundlers and a lot more. which MUI5/6/7 still lacks;
1 parent 86162bb commit 2ca9dda

File tree

14 files changed

+109
-64
lines changed

14 files changed

+109
-64
lines changed

babel.config.json

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,41 @@
4343
]
4444
]
4545
},
46+
"cjs2": {
47+
"presets": [
48+
"@babel/preset-env",
49+
[
50+
"@babel/preset-react",
51+
{
52+
"runtime": "automatic"
53+
}
54+
],
55+
"@babel/preset-typescript"
56+
],
57+
"plugins": [
58+
]
59+
},
60+
"mjs": {
61+
"presets": [
62+
[
63+
"@babel/preset-react",
64+
{
65+
"runtime": "automatic"
66+
}
67+
],
68+
"@babel/preset-typescript"
69+
],
70+
"plugins": [
71+
[
72+
"babel-plugin-replace-import-extension",
73+
{
74+
"extMapping": {
75+
".js": ".mjs"
76+
}
77+
}
78+
]
79+
]
80+
},
4681
"test": {
4782
"presets": [
4883
"@babel/preset-env",
@@ -61,7 +96,7 @@
6196
"@babel/preset-env",
6297
{
6398
"targets": {
64-
"node": "18"
99+
"node": "20"
65100
},
66101
"modules": false
67102
}
@@ -70,7 +105,7 @@
70105
"@babel/preset-typescript",
71106
{
72107
"targets": {
73-
"node": "18"
108+
"node": "20"
74109
},
75110
"modules": false
76111
}

eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ export default defineConfig([
235235
{
236236
files: [
237237
'**/demo-server/*.{ts,tsx,mjs,js}',
238-
'packerConfig.js',
238+
'packerConfig.{mjs,js}',
239239
'jest.config.ts',
240240
],
241241
languageOptions: {

package-lock.json

Lines changed: 7 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
"page-index": "lerna run page-index",
2121
"dtsgen": "lerna run dtsgen",
2222
"tscheck": "lerna run tscheck",
23-
"profile": "cross-env NODE_OPTIONS='--max-old-space-size=4096' NODE_ENV=production node packerConfig.mjs --build --profile",
23+
"profile": "cross-env NODE_OPTIONS='$NODE_OPTIONS --max-old-space-size=4096' NODE_ENV=production node packerConfig.mjs --build --profile",
2424
"clean": "npm run clean-dist && lerna clean -y",
2525
"clean-dist": "node packerConfig.mjs --clean",
2626
"clean-lock": "rimraf --glob packages/*/package-lock.json",
2727
"check": "npm run lint && npm run tscheck && npm run test",
28-
"lint": "cross-env NODE_ENV=test NODE_OPTIONS=\"--max-old-space-size=8192\" eslint -c=eslint.config.js --ext=.tsx,.ts --max-warnings=0 'packages'",
28+
"lint": "cross-env NODE_ENV=test NODE_OPTIONS=\"$NODE_OPTIONS --max-old-space-size=8192\" eslint -c=eslint.config.js --ext=.tsx,.ts --max-warnings=0 'packages'",
2929
"test": "jest -c=\"jest.config.ts\" --passWithNoTests",
3030
"tdd": "npm test -- --watch --watchman --coverage=false",
3131
"__release": "lerna run release --stream",
@@ -49,7 +49,7 @@
4949
"globals": "^16.2.0",
5050
"jest-environment-jsdom": "^29.0.2",
5151
"lerna": "^8.2.2",
52-
"lerna-packer": "0.12.1",
52+
"lerna-packer": "0.12.2",
5353
"nodemon": "^3.1.7",
5454
"react": "^19.0",
5555
"react-dom": "^19.0",

packages/material-code/package.json

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ui-schema/material-code",
3-
"version": "0.5.0-alpha.0",
3+
"version": "0.5.0-alpha.1",
44
"description": "Code editor widgets using CodeMirror, with Material-UI styling for UI-Schema",
55
"homepage": "https://ui-schema.bemit.codes/docs/material-code/material-code",
66
"author": {
@@ -34,9 +34,22 @@
3434
"bugs": {
3535
"url": "https://github.com/ui-schema/react-codemirror/issues"
3636
},
37-
"main": "./index.js",
37+
"main": "./index.cjs",
3838
"module": "./esm/index.js",
3939
"types": "./index.d.ts",
40+
"exports": {
41+
".": {
42+
"types": "./index.d.ts",
43+
"import": "./esm/index.js",
44+
"require": "./index.cjs"
45+
},
46+
"./*": {
47+
"types": "./*/index.d.ts",
48+
"import": "./esm/*/index.js",
49+
"require": "./*/index.cjs"
50+
},
51+
"./esm": null
52+
},
4053
"scripts": {
4154
"dtsgen": "tsc -d --emitDeclarationOnly --pretty && node ../../tools/merge-dirs.js build/dts/material-code/src build && rm -rf build/dts && rm -rf build/**/*.test.* build/**/*.mock.*",
4255
"__release": "cp package.json build/ && cp package-lock.json build/ && cp README.md build/ && npm publish build"
@@ -54,6 +67,7 @@
5467
"@ui-schema/kit-codemirror": "^1.0.0-alpha.0",
5568
"@ui-schema/ds-material": "~0.4.3",
5669
"@ui-schema/ui-schema": "~0.4.7",
70+
"@lezer/highlight": "^1.2.1",
5771
"immutable": "^5.0.0",
5872
"react": "^19.0",
5973
"react-dom": "^19.0"
@@ -67,6 +81,7 @@
6781
"@ui-schema/kit-codemirror": "^1.0.0-alpha.0",
6882
"@ui-schema/ds-material": "~0.4.0-alpha",
6983
"@ui-schema/ui-schema": "~0.4.0-alpha",
84+
"@lezer/highlight": "^1.0.0",
7085
"immutable": "^4.0.0 || ^5.0.0",
7186
"react": "^17.0 || ^18.0 || ^19.0"
7287
},
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from './CodeBar'
1+
export * from './CodeBar.js'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from './WidgetCode'
1+
export * from './WidgetCode.js'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from './WidgetCodeSelectable'
1+
export * from './WidgetCodeSelectable.js'
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
export * from './CodeBar'
2-
export * from './useEditorTheme'
3-
export * from './useHighlightStyle'
4-
export * from './WidgetCode'
5-
export * from './WidgetCodeSelectable'
1+
export * from '@ui-schema/material-code/CodeBar'
2+
export * from '@ui-schema/material-code/useEditorTheme'
3+
export * from '@ui-schema/material-code/useHighlightStyle'
4+
export * from '@ui-schema/material-code/WidgetCode'
5+
export * from '@ui-schema/material-code/WidgetCodeSelectable'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from './useEditorTheme'
1+
export * from './useEditorTheme.js'

0 commit comments

Comments
 (0)