Skip to content

Commit

Permalink
chore: support umd js
Browse files Browse the repository at this point in the history
  • Loading branch information
gusrb3164 committed Apr 2, 2022
1 parent aa5585f commit 6a68866
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 19 deletions.
19 changes: 14 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"name": "react-custom-alert",
"version": "0.1.2",
"version": "0.1.3",
"description": "Easliy use react alert and customize",
"module": "dist/index.esm.js",
"main": "dist/index.js",
"types": "dist/types/index.d.ts",
"scripts": {
"build": "rollup -c rollup.config.js",
"build:types": "tsc --emitDeclarationOnly"
"build": "rollup -c rollup.config.js && tsc --emitDeclarationOnly",
"lint": "eslint 'src/**/*.ts'"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -36,11 +37,19 @@
"devDependencies": {
"@rollup/plugin-typescript": "^8.2.5",
"@types/react": "^17.0.24",
"prettier": "^2.3.2",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-peer-deps-external": "^2.2.4",
"typescript": "^4.3.5"
"typescript": "^4.6.2",
"@typescript-eslint/eslint-plugin": "^5.15.0",
"@typescript-eslint/parser": "^5.15.0",
"eslint": "^8.11.0",
"eslint-config-prettier": "^8.5.0",
"eslint-import-resolver-alias": "^1.1.2",
"eslint-plugin-jest": "^26.1.1",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.29.4",
"eslint-plugin-react-hooks": "^4.3.0"
},
"files": [
"dist"
Expand Down
33 changes: 19 additions & 14 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
import typescript from '@rollup/plugin-typescript';
import commonjs from 'rollup-plugin-commonjs';
import resolve from 'rollup-plugin-node-resolve';
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
import typescript from "@rollup/plugin-typescript";
import commonjs from "rollup-plugin-commonjs";
import resolve from "rollup-plugin-node-resolve";
import peerDepsExternal from "rollup-plugin-peer-deps-external";

const extensions = ['.js', '.jsx', '.ts', '.tsx']; // 어떤 확장자를 처리 할 지 정함
const extensions = [".js", ".jsx", ".ts", ".tsx"];

export default {
input: './src/index.ts', // 어떤 파일부터 불러올지 정함.
input: "./src/index.ts",
plugins: [
typescript({ target: 'es5', sourceMap: true }),
peerDepsExternal() /* peerDependencies로 설치한 라이브러리들을 external 모듈로 설정
즉, 번들링된 결과에 포함시키지 않음 */,
resolve({ extensions }), // node_modules 에서 모듈을 불러올 수 있게 해줌. ts/tsx 파일도 불러올 수 있게 해줌
typescript({ target: "es5", sourceMap: true }),
peerDepsExternal(),
resolve({ extensions }),
commonjs({
include: 'node_modules/**',
}), // CommonJS 형태로 만들어진 모듈도 불러와서 사용 할 수 있게 해줌. 현재 프로젝트 상황에서는 없어도 무방함
include: "node_modules/**",
}),
],
output: [
{
sourcemap: true,
file: 'dist/index.js', // 번들링한 파일을 저장 할 경로
format: 'es', // ES Module 형태로 번들링함
file: "dist/index.esm.js",
format: "es",
},
{
name: "react-custom-alert",
sourcemap: true,
file: "dist/index.js",
format: "umd",
},
],
};

0 comments on commit 6a68866

Please sign in to comment.