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

[core] Restrict top level imports that target CJS modules #23159

Merged
merged 7 commits into from
Oct 28, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions .eslintrc.js
Expand Up @@ -52,6 +52,17 @@ module.exports = {
{
patterns: [
'@material-ui/*/*/*',
// Begin block: Packages with files instead of packages in the top level
// Importing from the top level pulls in CommonJS instead of ES modules
// Allowing /icons as to reduce cold-start of dev builds significantly.
// There's nothing to tree-shake when importing from /icons this way:
// '@material-ui/icons/*/',
'@material-ui/system/*',
'@material-ui/utils/*',
// End block
// Macros are fine since their import path is transpiled away
'!@material-ui/utils/macros',
'@material-ui/utils/macros/*',
'!@material-ui/utils/macros/*.macro',
// public API: https://next.material-ui-pickers.dev/getting-started/installation#peer-library
'!@material-ui/pickers/adapter/*',
Expand Down
1 change: 1 addition & 0 deletions azure-pipelines.yml
Expand Up @@ -98,6 +98,7 @@ steps:
displayName: Cache nextjs build

- script: |
set -o pipefail
mkdir -p scripts/sizeSnapshot/build
yarn docs:build | tee scripts/sizeSnapshot/build/docs.next
displayName: 'build docs for size snapshot'
Expand Down
5 changes: 2 additions & 3 deletions docs/src/modules/redux/optionsReducer.js
@@ -1,5 +1,4 @@
import { ACTION_TYPES, CODE_VARIANTS } from 'docs/src/modules/constants';
import memoize from '@material-ui/system/memoize';
import mapTranslations from 'docs/src/modules/utils/mapTranslations';

const req = require.context('docs/translations', false, /translations.*\.json$/);
Expand All @@ -15,7 +14,7 @@ function getPath(obj, path) {

const warnOnce = {};

const getT = memoize((userLanguage) => (key, options = {}) => {
eps1lon marked this conversation as resolved.
Show resolved Hide resolved
const getT = (userLanguage) => (key, options = {}) => {
const { ignoreWarning = false } = options;
const wordings = translations[userLanguage];

Expand All @@ -37,7 +36,7 @@ const getT = memoize((userLanguage) => (key, options = {}) => {
}

return translation;
});
};

const mapping = {
[ACTION_TYPES.OPTIONS_CHANGE]: (state, action) => {
Expand Down