Skip to content

Commit fe1b0a1

Browse files
committed
Issue #3 feat : Add Rollup config and typescript
1 parent 56d3d23 commit fe1b0a1

File tree

5 files changed

+395
-0
lines changed

5 files changed

+395
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
.DS_Store
3+
dist

package.json

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "wap-ui",
3+
"version": "1.0.0",
4+
"repository": "https://github.com/neko113/wap-ui.git",
5+
"author": "neko113 <[email protected]>",
6+
"license": "MIT",
7+
"main": "./dist/index.js",
8+
"module": "./dist/index.es.js",
9+
"types": "./dist/index.d.ts",
10+
"browser": "./dist/index.umd.js",
11+
"private": false,
12+
"scripts": {
13+
"build": "rollup -c"
14+
},
15+
"devDependencies": {
16+
"@rollup/plugin-babel": "^5.3.1",
17+
"@rollup/plugin-commonjs": "^22.0.2",
18+
"@rollup/plugin-node-resolve": "^14.1.0",
19+
"@rollup/plugin-typescript": "^8.5.0",
20+
"rollup": "^2.79.0",
21+
"rollup-plugin-peer-deps-external": "^2.2.4",
22+
"typescript": "^4.8.3"
23+
},
24+
"peerDependencies": {},
25+
"dependencies": {},
26+
"files": [
27+
"dist"
28+
]
29+
}

rollup.config.js

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import babel from "@rollup/plugin-babel";
2+
import commonjs from "@rollup/plugin-commonjs";
3+
import { nodeResolve } from "@rollup/plugin-node-resolve";
4+
import typescript from "@rollup/plugin-typescript";
5+
import peerDepsExternal from "rollup-plugin-peer-deps-external";
6+
7+
const extensions = ["js", "jsx", "ts", "tsx", "mjs"];
8+
const pkg = require("./package.json");
9+
10+
function setUpRollup({ output }) {
11+
return {
12+
external: ["react", "react-dom"],
13+
input: "./packages/index.ts",
14+
output,
15+
plugins: [
16+
nodeResolve({ extensions }),
17+
babel({
18+
exclude: "node_modules/**",
19+
extensions,
20+
include: ["packages/**/*"],
21+
babelHelpers: "bundled",
22+
}),
23+
commonjs({ include: "node_modules/**" }),
24+
peerDepsExternal(),
25+
typescript({ tsconfig: "./tsconfig.json" }),
26+
],
27+
};
28+
}
29+
30+
export default [
31+
setUpRollup({
32+
output: {
33+
file: pkg.main,
34+
format: "cjs",
35+
},
36+
}),
37+
setUpRollup({
38+
output: {
39+
file: pkg.module,
40+
format: "esm",
41+
},
42+
}),
43+
];

tsconfig.json

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5",
4+
"esModuleInterop": true,
5+
"forceConsistentCasingInFileNames": true,
6+
"strict": true,
7+
"skipLibCheck": true,
8+
"jsx": "react",
9+
"module": "ESNext",
10+
"declaration": true, // *.d.ts 타입 파일 생성 여부
11+
"declarationDir": "./dist", // *.d.ts 타입 파일 생성 경로
12+
"sourceMap": false,
13+
"outDir": "./dist", // 빌드 결과물이 저장될 경로
14+
"moduleResolution": "node",
15+
"allowSyntheticDefaultImports": true,
16+
"emitDeclarationOnly": true,
17+
"removeComments": true
18+
},
19+
"include": ["./packages"],
20+
"exclude": ["./dist", "./node_modules"]
21+
}

0 commit comments

Comments
 (0)