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

Don't pull unused @mui modules by using path imports #168

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 5 additions & 2 deletions rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const external = [
'@emotion/react/jsx-dev-runtime',
'@mui/material',
'@mui/material/styles',
/@mui\/material\/.*/,
'copy-to-clipboard',
'zustand',
'zustand/context',
Expand All @@ -47,7 +48,9 @@ const outputMatrix = (
format,
banner: `/// <reference types="./${baseName}.d.ts" />`,
globals: external.reduce((object, module) => {
object[module] = module
if (typeof module === 'string') {
object[module] = module
}
return object
}, {} as Record<string, string>)
}))
Expand Down Expand Up @@ -124,7 +127,7 @@ const dtsMatrix = (): RollupOptions[] => {

const build: RollupOptions[] = [
buildMatrix('./src/index.tsx', 'index', {
format: ['es', 'umd'],
format: ['es', 'cjs'],
browser: false,
dts: true
}),
Expand Down
2 changes: 1 addition & 1 deletion src/components/DataKeyPair.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box } from '@mui/material'
import Box from '@mui/material/Box'
import type { ComponentProps } from 'react'
import React, { useCallback, useMemo, useState } from 'react'

Expand Down
3 changes: 2 additions & 1 deletion src/components/DataTypes/Function.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
* Use NoSsr on function value.
* Because in Next.js SSR, the function will be translated to other type
*/
import { Box, NoSsr } from '@mui/material'
import Box from '@mui/material/Box'
import NoSsr from '@mui/material/NoSsr'
import React from 'react'

import { useJsonViewerStore } from '../../stores/JsonViewerStore'
Expand Down
2 changes: 1 addition & 1 deletion src/components/DataTypes/Object.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box } from '@mui/material'
import Box from '@mui/material/Box'
import React, { useMemo, useState } from 'react'

import { useTextColor } from '../../hooks/useColor'
Expand Down
2 changes: 1 addition & 1 deletion src/components/DataTypes/createEasyType.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { InputBase } from '@mui/material'
import InputBase from '@mui/material/InputBase'
import React, { useCallback } from 'react'

import { useJsonViewerStore } from '../../stores/JsonViewerStore'
Expand Down
2 changes: 1 addition & 1 deletion src/components/Icons.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { SvgIconProps } from '@mui/material'
import { SvgIcon } from '@mui/material'
import SvgIcon from '@mui/material/SvgIcon'
import React from 'react'

const BaseIcon: React.FC<SvgIconProps> = ({ d, ...props }) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/mui/DataBox.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box } from '@mui/material'
import Box from '@mui/material/Box'
import type { ComponentProps } from 'react'
import React from 'react'

Expand Down
7 changes: 3 additions & 4 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
createTheme, Paper,
ThemeProvider
} from '@mui/material'
import Paper from '@mui/material/Paper'
import createTheme from '@mui/material/styles/createTheme'
import ThemeProvider from '@mui/material/styles/ThemeProvider'
import React, { useCallback, useEffect, useMemo, useRef } from 'react'

import { DataKeyPair } from './components/DataKeyPair'
Expand Down
4 changes: 2 additions & 2 deletions src/stores/typeRegistry.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Box } from '@mui/material'
import Box from '@mui/material/Box'
import type { SetStateAction } from 'react'
import React, { memo, useMemo, useState } from 'react'
import { memo, useMemo, useState } from 'react'
import create from 'zustand'
import createStore from 'zustand/context'
import { combine } from 'zustand/middleware'
Expand Down