Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[code-infra] Update package layout for better ESM support #43264

Draft
wants to merge 54 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
0c2d530
WIP
Janpot Aug 11, 2024
f0cc38e
exclude icons
Janpot Aug 11, 2024
3955055
MUI_PACKAGE_EXPORTS
Janpot Aug 11, 2024
33c43c1
more
Janpot Aug 11, 2024
5888018
Update copyFilesUtils.mjs
Janpot Aug 11, 2024
642fdcd
remove deep export
Janpot Aug 12, 2024
868a81d
bring back flag
Janpot Aug 12, 2024
e03039f
Update ci.yml
Janpot Aug 12, 2024
f5bb040
WIP
Janpot Aug 12, 2024
da26652
Merge branch 'next' into esm-exports
Janpot Aug 23, 2024
4229626
Update build.mjs
Janpot Aug 23, 2024
c11b8e5
remove this
Janpot Aug 25, 2024
a98520b
fix snapshot
Janpot Aug 25, 2024
60e04ca
vite icons alias
Janpot Aug 25, 2024
6e2bbcc
remove 'use client' from index.* fles
Janpot Aug 25, 2024
9348956
Update package.json
Janpot Aug 25, 2024
860a36e
Update package.json
Janpot Aug 25, 2024
904f65b
Update package.json
Janpot Aug 25, 2024
0de01ee
Revert "remove 'use client' from index.* fles"
Janpot Aug 26, 2024
5172a89
bring changes to snashots
Janpot Aug 27, 2024
9eaa517
Update webpack.config.js
Janpot Aug 27, 2024
2011763
Merge remote-tracking branch 'upstream/master' into esm-exports
Janpot Aug 27, 2024
4c44355
Update scripts/build.mjs
Janpot Aug 28, 2024
626135d
Reapply "remove 'use client' from index.* fles"
Janpot Aug 28, 2024
b4e9968
remove 'use client'
Janpot Aug 28, 2024
6bf0206
Update pnpm-lock.yaml
Janpot Aug 28, 2024
ba50924
Merge remote-tracking branch 'upstream/master' into esm-exports
Janpot Aug 28, 2024
97f711a
fix tsc
Janpot Aug 28, 2024
f7b83b9
Update tsconfig.json
Janpot Aug 28, 2024
32afa8d
Merge branch 'master' into esm-exports
Janpot Aug 28, 2024
72beb0e
zis
Janpot Aug 28, 2024
bb746d1
update exports of icons
Janpot Aug 28, 2024
db13926
fix overrides of export field
Janpot Aug 28, 2024
ee3f56b
Merge branch 'master' into esm-exports
Janpot Aug 28, 2024
85e1af7
Update build.mjs
Janpot Aug 29, 2024
d881880
next document fix
Janpot Aug 30, 2024
66e9d33
ci
Janpot Aug 30, 2024
d4953d4
ci
Janpot Aug 30, 2024
c6212c5
Update pagesRouterV13Document.tsx
Janpot Aug 30, 2024
debe230
Update package.json
Janpot Aug 30, 2024
02749c1
Update package.json
Janpot Aug 30, 2024
c1061e7
Update package.json
Janpot Aug 30, 2024
ff6c473
remove mjs
Janpot Aug 31, 2024
096d907
remove unnecessary
Janpot Sep 2, 2024
6074ce9
extension
Janpot Sep 2, 2024
9aabf3b
Update copyFiles.mjs
Janpot Sep 2, 2024
3cccf14
Merge remote-tracking branch 'upstream/master' into esm-exports
Janpot Sep 4, 2024
eedc2b9
Revert
Janpot Sep 4, 2024
029389f
jdsh
Janpot Sep 4, 2024
b43e03e
Merge remote-tracking branch 'upstream/master' into esm-exports
Janpot Sep 23, 2024
a9bedd6
Update pnpm-lock.yaml
Janpot Sep 23, 2024
ea378ca
Update package.json
Janpot Sep 23, 2024
1d5d237
Update webpack.config.js
Janpot Sep 23, 2024
32a2605
Merge remote-tracking branch 'upstream/master' into esm-exports
Janpot Oct 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ default-job: &default-job
REACT_VERSION: << parameters.react-version >>
TEST_GATE: << parameters.test-gate >>
AWS_REGION_ARTIFACTS: eu-central-1
MUI_USE_PACKAGE_EXPORTS: 'true'
COREPACK_ENABLE_DOWNLOAD_PROMPT: '0'
working_directory: /tmp/material-ui
docker:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ on:

permissions: {}

env:
MUI_USE_PACKAGE_EXPORTS: 'true'

jobs:
# Tests dev-only scripts across all supported dev environments
test-dev:
Expand Down
17 changes: 5 additions & 12 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ module.exports = function getBabelConfig(api) {
'@babel/preset-env',
{
bugfixes: true,
browserslistEnv: process.env.BABEL_ENV || process.env.NODE_ENV,
browserslistEnv: api.env() || process.env.NODE_ENV,
debug: process.env.MUI_BUILD_VERBOSE === 'true',
modules: useESModules ? false : 'commonjs',
shippedProposals: api.env('modern'),
Expand All @@ -67,14 +67,9 @@ module.exports = function getBabelConfig(api) {
'@babel/preset-typescript',
];

const usesAliases =
// in this config:
api.env(['coverage', 'development', 'test', 'benchmark']) ||
process.env.NODE_ENV === 'test' ||
// in webpack config:
api.env(['regressions']);

const outFileExtension = '.js';
// Essentially only replace in production builds.
// When aliasing we want to keep the original extension
const outFileExtension = process.env.MUI_OUT_FILE_EXTENSION || null;

/** @type {babel.PluginItem[]} */
const plugins = [
Expand Down Expand Up @@ -119,9 +114,7 @@ module.exports = function getBabelConfig(api) {
[
'@mui/internal-babel-plugin-resolve-imports',
{
// Don't replace the extension when we're using aliases.
// Essentially only replace in production builds.
outExtension: usesAliases ? null : outFileExtension,
outExtension: outFileExtension,
},
],
]
Expand Down
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"build:ci": "lerna run build --ignore docs --concurrency 8 --skip-nx-cache",
"build:public": "lerna run --no-private build",
"build:public:ci": "lerna run --no-private build --concurrency 8 --skip-nx-cache",
"build:codesandbox": "NODE_OPTIONS=\"--max_old_space_size=4096\" lerna run --concurrency 8 --scope \"@mui/*\" --scope \"@mui-internal/*\" --no-private build",
"build:codesandbox": "MUI_USE_PACKAGE_EXPORTS=true NODE_OPTIONS=\"--max_old_space_size=4096\" lerna run --concurrency 8 --scope \"@mui/*\" --scope \"@mui-internal/*\" --no-private build",
"release:version": "lerna version --no-changelog --no-push --no-git-tag-version --no-private --force-publish=@mui/core-downloads-tracker",
"release:build": "lerna run --concurrency 8 --no-private build --skip-nx-cache",
"release:changelog": "node scripts/releaseChangelog.mjs",
Expand Down Expand Up @@ -96,7 +96,8 @@
"nx_test_karma": "cross-env NODE_ENV=test karma start test/karma.conf.js",
"nx_test_regressions_run": "mocha --config test/regressions/.mocharc.js --delay 'test/regressions/**/*.test.js'",
"nx_test_regressions_pigment_css_run": "mocha --config apps/pigment-css-vite-app/.mocharc.cjs --delay 'apps/pigment-css-vite-app/**/*.test.js'",
"nx_test_unit": "cross-env NODE_ENV=test mocha 'packages/**/*.test.{js,ts,tsx}' 'packages-internal/**/*.test.{js,ts,tsx}' 'docs/**/*.test.{js,ts,tsx}'"
"nx_test_unit": "cross-env NODE_ENV=test mocha 'packages/**/*.test.{js,ts,tsx}' 'packages-internal/**/*.test.{js,ts,tsx}' 'docs/**/*.test.{js,ts,tsx}'",
"clean": "pnpm -r exec rm -rf build"
},
"dependencies": {
"@googleapis/sheets": "^9.3.1",
Expand Down Expand Up @@ -127,6 +128,9 @@
"@next/eslint-plugin-next": "^14.2.13",
"@octokit/rest": "^21.0.2",
"@pigment-css/react": "0.0.23",
"@rollup/plugin-alias": "^5.1.0",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-node-resolve": "^15.2.3",
"@playwright/test": "1.47.2",
"@types/babel__core": "^7.20.5",
"@types/fs-extra": "^11.0.4",
Expand Down Expand Up @@ -188,6 +192,8 @@
"pretty-quick": "^4.0.0",
"process": "^0.11.10",
"rimraf": "^6.0.1",
"rollup": "^4.20.0",
"rollup-plugin-preserve-directives": "^0.4.0",
"serve": "^14.2.3",
"stylelint": "^15.11.0",
"stylelint-config-standard": "^34.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/mui-icons-material/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
},
"scripts": {
"build": "shx cp -r lib/ build/ && pnpm build:typings && pnpm build:copy-files",
"build:lib": "pnpm build:node && pnpm build:stable",
"build:lib": "cross-env MUI_USE_PACKAGE_EXPORTS=false pnpm build:node && cross-env MUI_USE_PACKAGE_EXPORTS=false pnpm build:stable",
"build:lib:clean": "rimraf lib/ && pnpm build:lib",
"build:modern": "echo 'Skip modern build'",
"build:node": "node ../../scripts/build.mjs node --largeFiles --outDir lib",
"build:stable": "node ../../scripts/build.mjs stable --largeFiles --outDir lib",
"build:copy-files": "node ../../scripts/copyFiles.mjs",
"build:copy-files": "cross-env MUI_USE_PACKAGE_EXPORTS=false node ../../scripts/copyFiles.mjs",
"build:typings": "node ./scripts/create-typings.mjs",
"prebuild": "rimraf build",
"release": "pnpm build && pnpm publish",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('next/document');
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ import * as React from 'react';
import { AppType } from 'next/app';
import { EmotionCache } from '@emotion/react';
import createEmotionServer from '@emotion/server/create-instance';
import Document, { DocumentContext, DocumentInitialProps } from 'next/document';
import type { DocumentContext, DocumentInitialProps } from 'next/document';
import nextDocument from './nextDocument.cjs';
import { EmotionCacheProviderProps } from './pagesRouterV13App';
import createEmotionCache from './createCache';

const Document = nextDocument.default || nextDocument;

interface Plugin {
enhanceApp: (
App: React.ComponentType<React.ComponentProps<AppType>>,
Expand Down
4 changes: 2 additions & 2 deletions packages/mui-material-nextjs/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"outDir": "build",
"rootDir": "./src"
},
"include": ["./src/**/*.ts*"],
"exclude": ["src/**/*.spec.ts*", "src/**/*.test.ts*"]
"include": ["./src/**/*"],
"exclude": ["src/**/*.spec.*", "src/**/*.test.*"]
}
4 changes: 4 additions & 0 deletions packages/mui-material-pigment-css/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@
"useTheme": "@pigment-css/react/exports/useTheme"
}
},
"exports": {
"./styles.css": "./styles.css",
"./modern/styles.css": "./styles.css"
},
"engines": {
"node": ">=14.0.0"
}
Expand Down
8 changes: 8 additions & 0 deletions packages/mui-material/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@
"engines": {
"node": ">=14.0.0"
},
"exports": {
"./ButtonBase/TouchRipple": {
"types": "./ButtonBase/TouchRipple.d.ts",
"import": "./ButtonBase/TouchRipple.mjs",
"mui-modern": "./ButtonBase/TouchRipple.modern.mjs",
"require": "./ButtonBase/TouchRipple.js"
}
},
"pigment-css": {
"vite": {
"include": [
Expand Down
8 changes: 4 additions & 4 deletions packages/mui-material/src/PigmentGrid/PigmentGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import Grid from '@mui/material-pigment-css/Grid';
import composeClasses from '@mui/utils/composeClasses';
import generateUtilityClass from '@mui/utils/generateUtilityClass';
import {
generateDirectionClasses,
generateSizeClassNames,
generateSpacingClassNames,
} from '@mui/system/Grid/gridGenerator';
unstable_generateDirectionClasses as generateDirectionClasses,
unstable_generateSizeClassNames as generateSizeClassNames,
unstable_generateSpacingClassNames as generateSpacingClassNames,
} from '@mui/system/Grid';
import { Breakpoint, Theme } from '../styles';

type ResponsiveStyleValue<T> = T | Array<T | null> | { [key in Breakpoint]?: T | null };
Expand Down
5 changes: 5 additions & 0 deletions packages/mui-system/src/Grid/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ export * from './GridProps';
export { default as gridClasses } from './gridClasses';
export * from './gridClasses';
export { traverseBreakpoints as unstable_traverseBreakpoints } from './traverseBreakpoints';
export {
generateDirectionClasses as unstable_generateDirectionClasses,
generateSizeClassNames as unstable_generateSizeClassNames,
generateSpacingClassNames as unstable_generateSpacingClassNames,
} from './gridGenerator';
92 changes: 92 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading