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

chore: modern-kit/react build setting update #706

Merged
merged 3 commits into from
Jan 23, 2025
Merged
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
6 changes: 6 additions & 0 deletions .changeset/thick-hotels-refuse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@modern-kit/react': minor
'@modern-kit/utils': minor
---

chore: update react/utils build setting - @ssi02014
77 changes: 35 additions & 42 deletions .pnp.cjs

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

Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions docs/docs/react/components/AspectRatio.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useState } from 'react';
import { AspectRatio } from '@modern-kit/react';
import { AspectRatio } from '@modern-kit/react/components/AspectRatio';
import { useStep } from '@modern-kit/react/hooks/useStep';

# AspectRatio

Expand Down Expand Up @@ -100,7 +101,6 @@ const Example = () => {

export const Example = () => {
const imgUrl = 'https://github.com/user-attachments/assets/dd60ec12-afd7-44c9-bd6b-0069e16bf2c9';

return (
<div style={{ width: '500px' }}>
<h3>Default</h3>
Expand Down
6 changes: 5 additions & 1 deletion packages/react/build.utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ export const getFormatEntryFileNames = (chunkInfo, format) => {

export const getSubEntryMap = (keys, path) => {
return keys.reduce((acc, entry) => {
acc[`${path}-${entry}`] = `./src/${path}/${entry}`;
acc[`${path}-${entry}`] = `./src/${path}/${
entry === 'index'
? 'index.ts'
: `${entry}/index.${path === 'components' ? 'tsx' : 'ts'}`
}`;
return acc;
}, {});
};
5 changes: 2 additions & 3 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
"author": "ssi02014 <[email protected]>",
"license": "MIT",
"devDependencies": {
"@modern-kit/utils": "workspace:^",
"@rollup/plugin-commonjs": "^28.0.0",
"@rollup/plugin-node-resolve": "^16.0.0",
"@rollup/plugin-typescript": "^12.1.0",
"@testing-library/dom": "^10.0.0",
"@testing-library/jest-dom": "^6.5.0",
"@testing-library/react": "^16.2.0",
Expand All @@ -36,6 +36,7 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"rollup": "^4.24.0",
"rollup-plugin-dts": "^6.1.1",
"rollup-plugin-esbuild": "^6.1.1",
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-postcss": "^4.0.2",
Expand All @@ -44,11 +45,9 @@
"vitest": "^3.0.2"
},
"dependencies": {
"@modern-kit/utils": "^2.0.2",
"@types/lodash-es": "^4.17.12",
"classnames": "^2.5.1",
"lodash-es": "^4.17.21",
"tslib": "^2.8.1",
"ua-parser-js": "^1.0.39"
},
"peerDependencies": {
Expand Down
101 changes: 58 additions & 43 deletions packages/react/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import nodeResolve from '@rollup/plugin-node-resolve';
import typescript from '@rollup/plugin-typescript';
import commonjs from '@rollup/plugin-commonjs';
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
import pkg from './package.json' assert { type: 'json' };
import esbuild from 'rollup-plugin-esbuild';
import postcss from 'rollup-plugin-postcss';
import autoprefixer from 'autoprefixer';
import { dts } from 'rollup-plugin-dts';

import {
componentsPathKeys,
Expand All @@ -17,46 +17,61 @@ import { getSubEntryMap, getFormatEntryFileNames } from './build.utils.mjs';

const extensions = ['.js', '.jsx', '.ts', '.tsx'];

export default {
preserveModules: true,
input: {
index: './src/index.ts', // 진입 경로,
...getSubEntryMap(componentsPathKeys, 'components'),
...getSubEntryMap(hooksPathKeys, 'hooks'),
...getSubEntryMap(utilsPathKey, 'utils'),
},
output: [
{
dir: './dist',
sourcemap: true,
format: 'cjs',
entryFileNames: (chunkInfo) => getFormatEntryFileNames(chunkInfo, 'cjs'),
},
{
dir: './dist',
sourcemap: true,
format: 'esm',
entryFileNames: (chunkInfo) => getFormatEntryFileNames(chunkInfo, 'mjs'),
},
],
external: [
...Object.keys(pkg.dependencies),
...Object.keys(pkg.peerDependencies),
],
plugins: [
peerDepsExternal(),
nodeResolve({
extensions,
}),
typescript({
exclude: ['**/*.spec.tsx', '**/*.spec.ts', './src/_internal/test/*'],
}),
commonjs(),
esbuild(),
postcss({
modules: true,
minimize: true,
plugins: [autoprefixer()],
}),
],
const input = {
index: './src/index.ts', // 진입 경로,
...getSubEntryMap(componentsPathKeys, 'components'),
...getSubEntryMap(hooksPathKeys, 'hooks'),
...getSubEntryMap(utilsPathKey, 'utils'),
};

export default [
{
input,
output: [
{
dir: './dist',
sourcemap: true,
format: 'cjs',
entryFileNames: (chunkInfo) =>
getFormatEntryFileNames(chunkInfo, 'cjs'),
chunkFileNames: `_chunk/[name]-[hash:6].cjs`,
},
{
dir: './dist',
sourcemap: true,
format: 'esm',
entryFileNames: (chunkInfo) =>
getFormatEntryFileNames(chunkInfo, 'mjs'),
chunkFileNames: `_chunk/[name]-[hash:6].mjs`,
},
],
external: [
...Object.keys(pkg.dependencies),
...Object.keys(pkg.peerDependencies),
],
plugins: [
peerDepsExternal(),
nodeResolve({ extensions }),
commonjs(),
esbuild(),
postcss({
modules: true,
minimize: true,
plugins: [autoprefixer()],
}),
],
},
{
// d.ts 파일 직접 생성
input,
output: [
{
dir: 'dist',
entryFileNames: (chunkInfo) =>
getFormatEntryFileNames(chunkInfo, 'd.ts'),
chunkFileNames: `_chunk/[name]-[hash:6].d.ts`,
},
],
plugins: [dts()],
},
];
2 changes: 1 addition & 1 deletion packages/react/src/hooks/useTimeout/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function useTimeout(
const { delay, enabled } = getTimeoutOptions(options);

const set = useCallback(() => {
timeoutRef.current = setTimeout(callbackAction, delay);
timeoutRef.current = window.setTimeout(callbackAction, delay);
}, [callbackAction, delay]);

const clear = useCallback(() => {
Expand Down
1 change: 1 addition & 0 deletions packages/react/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
"baseUrl": "./src",
"outDir": "./dist",
"skipLibCheck": true,
"rootDir": "./src"
},
}
4 changes: 3 additions & 1 deletion packages/utils/build.utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ export const getFormatEntryFileNames = (chunkInfo, format) => {

export const getSubEntryMap = (keys, path) => {
return keys.reduce((acc, entry) => {
acc[`${path}-${entry}`] = `./src/${path}/${entry}`;
acc[`${path}-${entry}`] = `./src/${path}/${
entry === 'index' ? 'index.ts' : `${entry}/index.ts`
}`;
return acc;
}, {});
};
7 changes: 2 additions & 5 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@
"devDependencies": {
"@rollup/plugin-commonjs": "^28.0.0",
"@rollup/plugin-node-resolve": "^16.0.0",
"@rollup/plugin-typescript": "^12.1.0",
"@types/lodash-es": "^4.17.12",
"@vitest/coverage-istanbul": "^3.0.3",
"esbuild": "^0.24.0",
"jsdom": "^25.0.0",
"lodash-es": "^4.17.21",
"rollup": "^4.24.0",
"rollup-plugin-dts": "^6.1.1",
"rollup-plugin-esbuild": "^6.1.1",
"typescript": "^5.1.6",
"vitest": "^3.0.2"
Expand All @@ -62,8 +62,5 @@
"hooks",
"custom hooks"
],
"gitHead": "7722785374b897572934e335817ec297ad45a943",
"dependencies": {
"tslib": "^2.8.1"
}
"gitHead": "7722785374b897572934e335817ec297ad45a943"
}
Loading
Loading