diff --git a/configuration/rollup/create-package-config.ts b/configuration/rollup/create-package-config.ts index a54eee00619..39a32798c2f 100644 --- a/configuration/rollup/create-package-config.ts +++ b/configuration/rollup/create-package-config.ts @@ -97,6 +97,8 @@ export default async function createPackageConfig(config: PkgConfigInput): Promi if (config.format === 'es') { output.dir = path.resolve(config.basePath, 'esm'); output.preserveModules = true; + // Output ESM as .mjs files + output.entryFileNames = '[name].mjs'; } if (config.format === 'cjs') { diff --git a/scripts/utils/generate-dts.ts b/scripts/utils/generate-dts.ts index 7ceb2c2bd93..5784aab7b5a 100644 --- a/scripts/utils/generate-dts.ts +++ b/scripts/utils/generate-dts.ts @@ -10,5 +10,11 @@ export default async function generateDts(packagePath: string) { const files = await fg(['lib/**/*.js'], { cwd: packagePath }); + // Duplicate the type definitions for ESM + await fs.copy( + path.join(packagePath, 'lib/index.d.ts'), + path.join(packagePath, 'lib/index.d.mts') + ); + return Promise.all(files.map((file) => fs.remove(path.join(packagePath, file)))); } diff --git a/src/mantine-carousel/package.json b/src/mantine-carousel/package.json index a9b2b2fb3d9..69003913238 100644 --- a/src/mantine-carousel/package.json +++ b/src/mantine-carousel/package.json @@ -2,13 +2,19 @@ "name": "@mantine/carousel", "description": "Embla based carousel", "version": "7.0.0", + "main": "./cjs/index.js", "types": "./lib/index.d.ts", - "module": "./esm/index.js", + "module": "./esm/index.mjs", "exports": { ".": { - "import": "./esm/index.js", - "require": "./cjs/index.js", - "types": "./lib/index.d.ts" + "import": { + "types": "./lib/index.d.mts", + "default": "./esm/index.mjs" + }, + "require": { + "types": "./lib/index.d.ts", + "default": "./cjs/index.js" + } }, "./styles.css": "./esm/index.css", "./styles/*": "./esm/styles/*" diff --git a/src/mantine-code-highlight/package.json b/src/mantine-code-highlight/package.json index 739a21cc2c9..b59eee7c617 100644 --- a/src/mantine-code-highlight/package.json +++ b/src/mantine-code-highlight/package.json @@ -2,13 +2,19 @@ "name": "@mantine/code-highlight", "description": "Code highlight with Mantine theme", "version": "7.0.0", + "main": "./cjs/index.js", "types": "./lib/index.d.ts", - "module": "./esm/index.js", + "module": "./esm/index.mjs", "exports": { ".": { - "import": "./esm/index.js", - "require": "./cjs/index.js", - "types": "./lib/index.d.ts" + "import": { + "types": "./lib/index.d.mts", + "default": "./esm/index.mjs" + }, + "require": { + "types": "./lib/index.d.ts", + "default": "./cjs/index.js" + } }, "./styles.css": "./esm/index.css" }, diff --git a/src/mantine-colors-generator/package.json b/src/mantine-colors-generator/package.json index 7820154d4b4..4617e592565 100644 --- a/src/mantine-colors-generator/package.json +++ b/src/mantine-colors-generator/package.json @@ -1,13 +1,19 @@ { "name": "@mantine/colors-generator", "version": "7.0.0", + "main": "./cjs/index.js", "types": "./lib/index.d.ts", - "module": "./esm/index.js", + "module": "./esm/index.mjs", "exports": { ".": { - "import": "./esm/index.js", - "require": "./cjs/index.js", - "types": "./lib/index.d.ts" + "import": { + "types": "./lib/index.d.mts", + "default": "./esm/index.mjs" + }, + "require": { + "types": "./lib/index.d.ts", + "default": "./cjs/index.js" + } } }, "license": "MIT", diff --git a/src/mantine-core/package.json b/src/mantine-core/package.json index 72bd856d702..189909286ef 100644 --- a/src/mantine-core/package.json +++ b/src/mantine-core/package.json @@ -2,13 +2,19 @@ "name": "@mantine/core", "description": "React components library focused on usability, accessibility and developer experience", "version": "7.0.0", + "main": "./cjs/index.js", "types": "./lib/index.d.ts", - "module": "./esm/index.js", + "module": "./esm/index.mjs", "exports": { ".": { - "import": "./esm/index.js", - "require": "./cjs/index.js", - "types": "./lib/index.d.ts" + "import": { + "types": "./lib/index.d.mts", + "default": "./esm/index.mjs" + }, + "require": { + "types": "./lib/index.d.ts", + "default": "./cjs/index.js" + } }, "./styles.css": "./esm/index.css", "./styles/*": "./esm/styles/*" diff --git a/src/mantine-dates-tests/package.json b/src/mantine-dates-tests/package.json index 39d0afebc01..f056bfdf823 100644 --- a/src/mantine-dates-tests/package.json +++ b/src/mantine-dates-tests/package.json @@ -2,12 +2,19 @@ "name": "@mantine/dates-tests", "private": true, "version": "7.0.0", + "main": "./cjs/index.js", "types": "./lib/index.d.ts", - "module": "./esm/index.js", + "module": "./esm/index.mjs", "exports": { ".": { - "import": "./esm/index.js", - "require": "./cjs/index.js" + "import": { + "types": "./lib/index.d.mts", + "default": "./esm/index.mjs" + }, + "require": { + "types": "./lib/index.d.ts", + "default": "./cjs/index.js" + } } }, "license": "MIT", diff --git a/src/mantine-dates/package.json b/src/mantine-dates/package.json index 61380c238d6..41d55367e8f 100644 --- a/src/mantine-dates/package.json +++ b/src/mantine-dates/package.json @@ -2,13 +2,19 @@ "name": "@mantine/dates", "description": "Calendars, date and time pickers based on Mantine components", "version": "7.0.0", + "main": "./cjs/index.js", "types": "./lib/index.d.ts", - "module": "./esm/index.js", + "module": "./esm/index.mjs", "exports": { ".": { - "import": "./esm/index.js", - "require": "./cjs/index.js", - "types": "./lib/index.d.ts" + "import": { + "types": "./lib/index.d.mts", + "default": "./esm/index.mjs" + }, + "require": { + "types": "./lib/index.d.ts", + "default": "./cjs/index.js" + } }, "./styles.css": "./esm/index.css" }, diff --git a/src/mantine-demos/package.json b/src/mantine-demos/package.json index fff8ce9e998..37d935015e1 100644 --- a/src/mantine-demos/package.json +++ b/src/mantine-demos/package.json @@ -3,13 +3,19 @@ "description": "Demos used in documentation", "private": true, "version": "7.0.0", + "main": "./cjs/index.js", "types": "./lib/index.d.ts", - "module": "./esm/index.js", + "module": "./esm/index.mjs", "exports": { ".": { - "import": "./esm/index.js", - "require": "./cjs/index.js", - "types": "./lib/index.d.ts" + "import": { + "types": "./lib/index.d.mts", + "default": "./esm/index.mjs" + }, + "require": { + "types": "./lib/index.d.ts", + "default": "./cjs/index.js" + } }, "./styles.css": "./esm/index.css" }, diff --git a/src/mantine-dropzone/package.json b/src/mantine-dropzone/package.json index 91781488030..90de3ddb7f0 100644 --- a/src/mantine-dropzone/package.json +++ b/src/mantine-dropzone/package.json @@ -2,13 +2,19 @@ "name": "@mantine/dropzone", "description": "Dropzone component built with Mantine theme and components", "version": "7.0.0", + "main": "./cjs/index.js", "types": "./lib/index.d.ts", - "module": "./esm/index.js", + "module": "./esm/index.mjs", "exports": { ".": { - "import": "./esm/index.js", - "require": "./cjs/index.js", - "types": "./lib/index.d.ts" + "import": { + "types": "./lib/index.d.mts", + "default": "./esm/index.mjs" + }, + "require": { + "types": "./lib/index.d.ts", + "default": "./cjs/index.js" + } }, "./styles.css": "./esm/index.css" }, diff --git a/src/mantine-ds/package.json b/src/mantine-ds/package.json index 05a29c1aa3f..6781ad7f317 100644 --- a/src/mantine-ds/package.json +++ b/src/mantine-ds/package.json @@ -2,13 +2,19 @@ "name": "@mantine/ds", "description": "Internal Mantine components used on *.mantine.dev websites", "version": "7.0.0", + "main": "./cjs/index.js", "types": "./lib/index.d.ts", - "module": "./esm/index.js", + "module": "./esm/index.mjs", "exports": { ".": { - "import": "./esm/index.js", - "require": "./cjs/index.js", - "types": "./lib/index.d.ts" + "import": { + "types": "./lib/index.d.mts", + "default": "./esm/index.mjs" + }, + "require": { + "types": "./lib/index.d.ts", + "default": "./cjs/index.js" + } }, "./styles.css": "./esm/index.css" }, diff --git a/src/mantine-form/package.json b/src/mantine-form/package.json index d883abe9791..f8976c58a74 100644 --- a/src/mantine-form/package.json +++ b/src/mantine-form/package.json @@ -2,13 +2,19 @@ "name": "@mantine/form", "description": "Mantine form management library", "version": "7.0.0", + "main": "./cjs/index.js", "types": "./lib/index.d.ts", - "module": "./esm/index.js", + "module": "./esm/index.mjs", "exports": { ".": { - "import": "./esm/index.js", - "require": "./cjs/index.js", - "types": "./lib/index.d.ts" + "import": { + "types": "./lib/index.d.mts", + "default": "./esm/index.mjs" + }, + "require": { + "types": "./lib/index.d.ts", + "default": "./cjs/index.js" + } } }, "license": "MIT", diff --git a/src/mantine-hooks/package.json b/src/mantine-hooks/package.json index 341dcfbd48f..5b2dbb89f5e 100644 --- a/src/mantine-hooks/package.json +++ b/src/mantine-hooks/package.json @@ -1,13 +1,19 @@ { "name": "@mantine/hooks", "version": "7.0.0", + "main": "./cjs/index.js", "types": "./lib/index.d.ts", - "module": "./esm/index.js", + "module": "./esm/index.mjs", "exports": { ".": { - "import": "./esm/index.js", - "require": "./cjs/index.js", - "types": "./lib/index.d.ts" + "import": { + "types": "./lib/index.d.mts", + "default": "./esm/index.mjs" + }, + "require": { + "types": "./lib/index.d.ts", + "default": "./cjs/index.js" + } } }, "license": "MIT", diff --git a/src/mantine-modals/package.json b/src/mantine-modals/package.json index 18c354c8eeb..4d3c84cdaeb 100644 --- a/src/mantine-modals/package.json +++ b/src/mantine-modals/package.json @@ -2,13 +2,19 @@ "name": "@mantine/modals", "description": "Modals manager based on Mantine components", "version": "7.0.0", + "main": "./cjs/index.js", "types": "./lib/index.d.ts", - "module": "./esm/index.js", + "module": "./esm/index.mjs", "exports": { ".": { - "import": "./esm/index.js", - "require": "./cjs/index.js", - "types": "./lib/index.d.ts" + "import": { + "types": "./lib/index.d.mts", + "default": "./esm/index.mjs" + }, + "require": { + "types": "./lib/index.d.ts", + "default": "./cjs/index.js" + } }, "./styles.css": "./esm/index.css" }, diff --git a/src/mantine-notifications/package.json b/src/mantine-notifications/package.json index 4ff88a3da1c..9953238a4ed 100644 --- a/src/mantine-notifications/package.json +++ b/src/mantine-notifications/package.json @@ -1,13 +1,19 @@ { "name": "@mantine/notifications", "version": "7.0.0", + "main": "./cjs/index.js", "types": "./lib/index.d.ts", - "module": "./esm/index.js", + "module": "./esm/index.mjs", "exports": { ".": { - "import": "./esm/index.js", - "require": "./cjs/index.js", - "types": "./lib/index.d.ts" + "import": { + "types": "./lib/index.d.mts", + "default": "./esm/index.mjs" + }, + "require": { + "types": "./lib/index.d.ts", + "default": "./cjs/index.js" + } }, "./styles.css": "./esm/index.css" }, diff --git a/src/mantine-nprogress/package.json b/src/mantine-nprogress/package.json index 21e09cb7580..0935eb360b7 100644 --- a/src/mantine-nprogress/package.json +++ b/src/mantine-nprogress/package.json @@ -2,13 +2,19 @@ "name": "@mantine/nprogress", "description": "Navigation progress bar", "version": "7.0.0", + "main": "./cjs/index.js", "types": "./lib/index.d.ts", - "module": "./esm/index.js", + "module": "./esm/index.mjs", "exports": { ".": { - "import": "./esm/index.js", - "require": "./cjs/index.js", - "types": "./lib/index.d.ts" + "import": { + "types": "./lib/index.d.mts", + "default": "./esm/index.mjs" + }, + "require": { + "types": "./lib/index.d.ts", + "default": "./cjs/index.js" + } }, "./styles.css": "./esm/index.css" }, diff --git a/src/mantine-spotlight/package.json b/src/mantine-spotlight/package.json index 9e328539074..13f68647718 100644 --- a/src/mantine-spotlight/package.json +++ b/src/mantine-spotlight/package.json @@ -1,13 +1,19 @@ { "name": "@mantine/spotlight", "version": "7.0.0", + "main": "./cjs/index.js", "types": "./lib/index.d.ts", - "module": "./esm/index.js", + "module": "./esm/index.mjs", "exports": { ".": { - "import": "./esm/index.js", - "require": "./cjs/index.js", - "types": "./lib/index.d.ts" + "import": { + "types": "./lib/index.d.mts", + "default": "./esm/index.mjs" + }, + "require": { + "types": "./lib/index.d.ts", + "default": "./cjs/index.js" + } }, "./styles.css": "./esm/index.css" }, diff --git a/src/mantine-store/package.json b/src/mantine-store/package.json index 7d932f3f5ca..d93ec63694e 100644 --- a/src/mantine-store/package.json +++ b/src/mantine-store/package.json @@ -1,13 +1,19 @@ { "name": "@mantine/store", "version": "7.0.0", + "main": "./cjs/index.js", "types": "./lib/index.d.ts", - "module": "./esm/index.js", + "module": "./esm/index.mjs", "exports": { ".": { - "import": "./esm/index.js", - "require": "./cjs/index.js", - "types": "./lib/index.d.ts" + "import": { + "types": "./lib/index.d.mts", + "default": "./esm/index.mjs" + }, + "require": { + "types": "./lib/index.d.ts", + "default": "./cjs/index.js" + } } }, "license": "MIT", diff --git a/src/mantine-styles-api/package.json b/src/mantine-styles-api/package.json index 97ba4765d83..68e267e3495 100644 --- a/src/mantine-styles-api/package.json +++ b/src/mantine-styles-api/package.json @@ -3,13 +3,19 @@ "description": "Mantine components styles api descriptions", "private": true, "version": "7.0.0", + "main": "./cjs/index.js", "types": "./lib/index.d.ts", - "module": "./esm/index.js", + "module": "./esm/index.mjs", "exports": { ".": { - "import": "./esm/index.js", - "require": "./cjs/index.js", - "types": "./lib/index.d.ts" + "import": { + "types": "./lib/index.d.mts", + "default": "./esm/index.mjs" + }, + "require": { + "types": "./lib/index.d.ts", + "default": "./cjs/index.js" + } } }, "license": "MIT", diff --git a/src/mantine-tests/package.json b/src/mantine-tests/package.json index 2449a9184db..e7d578b39ec 100644 --- a/src/mantine-tests/package.json +++ b/src/mantine-tests/package.json @@ -2,12 +2,19 @@ "name": "@mantine/tests", "private": true, "version": "7.0.0", + "main": "./cjs/index.js", "types": "./lib/index.d.ts", - "module": "./esm/index.js", + "module": "./esm/index.mjs", "exports": { ".": { - "import": "./esm/index.js", - "require": "./cjs/index.js" + "import": { + "types": "./lib/index.d.mts", + "default": "./esm/index.mjs" + }, + "require": { + "types": "./lib/index.d.ts", + "default": "./cjs/index.js" + } } }, "license": "MIT", diff --git a/src/mantine-tiptap/package.json b/src/mantine-tiptap/package.json index 15e262437cf..6f6a096b7cf 100644 --- a/src/mantine-tiptap/package.json +++ b/src/mantine-tiptap/package.json @@ -2,13 +2,19 @@ "name": "@mantine/tiptap", "description": "Rich text editor based on tiptap", "version": "7.0.0", + "main": "./cjs/index.js", "types": "./lib/index.d.ts", - "module": "./esm/index.js", + "module": "./esm/index.mjs", "exports": { ".": { - "import": "./esm/index.js", - "require": "./cjs/index.js", - "types": "./lib/index.d.ts" + "import": { + "types": "./lib/index.d.mts", + "default": "./esm/index.mjs" + }, + "require": { + "types": "./lib/index.d.ts", + "default": "./cjs/index.js" + } }, "./styles.css": "./esm/index.css" }, diff --git a/src/mantine-vanilla-extract/package.json b/src/mantine-vanilla-extract/package.json index 47b23dc7bf4..83a6f657db3 100644 --- a/src/mantine-vanilla-extract/package.json +++ b/src/mantine-vanilla-extract/package.json @@ -1,13 +1,19 @@ { "name": "@mantine/vanilla-extract", "version": "7.0.0", + "main": "./cjs/index.js", "types": "./lib/index.d.ts", - "module": "./esm/index.js", + "module": "./esm/index.mjs", "exports": { ".": { - "import": "./esm/index.js", - "require": "./cjs/index.js", - "types": "./lib/index.d.ts" + "import": { + "types": "./lib/index.d.mts", + "default": "./esm/index.mjs" + }, + "require": { + "types": "./lib/index.d.ts", + "default": "./cjs/index.js" + } } }, "license": "MIT",