makepack 1.7.10 → 1.7.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +122 -122
- package/package.json +62 -62
- package/src/actions/build/bundler.js +115 -113
- package/src/actions/build/index.js +74 -74
- package/src/actions/create/files/gitignore.js +9 -9
- package/src/actions/create/files/main.js +36 -36
- package/src/actions/create/files/package-json.js +49 -49
- package/src/actions/create/files/project-js.js +12 -12
- package/src/actions/create/files/project-jsx.js +50 -50
- package/src/actions/create/files/project-ts.js +10 -10
- package/src/actions/create/files/project-tsx.js +50 -50
- package/src/actions/create/files/readme.md.js +62 -62
- package/src/actions/create/files/tsconfig.js +33 -33
- package/src/actions/create/index.js +95 -95
- package/src/actions/create/makeFiles.js +65 -65
- package/src/actions/release/index.js +19 -19
- package/src/actions/start/index.js +176 -176
- package/src/actions/start/vite.js +68 -61
- package/src/helpers.js +52 -52
- package/src/index.js +39 -39
package/README.md
CHANGED
|
@@ -1,122 +1,122 @@
|
|
|
1
|
-
<p align="center">
|
|
2
|
-
<a href="https://github.com/devnax/makepack" rel="noopener" target="_blank"><img src="https://raw.githubusercontent.com/devnax/makepack/main/logo.png" alt="Makepack logo"></a>
|
|
3
|
-
</p>
|
|
4
|
-
|
|
5
|
-
<h1 align="center">Makepack</h1>
|
|
6
|
-
|
|
7
|
-
**MakePack** is a command-line interface (CLI) tool that helps you to quickly set up, build, and manage JavaScript, TypeScript, React, and React-TypeScript libraries for use in npm projects. With just a few simple commands, you can generate your own libraries, start a development server, or build and publish your project to the npm repository.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
## 📥 Installation
|
|
11
|
-
|
|
12
|
-
Install `makepack` globally to get started:
|
|
13
|
-
|
|
14
|
-
```sh
|
|
15
|
-
npm install -g makepack
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
---
|
|
19
|
-
|
|
20
|
-
## 🎯 Why Choose makepack?
|
|
21
|
-
- **Zero-Config Setup** – Instantly scaffold a structured project.
|
|
22
|
-
- **TypeScript Support** – Seamlessly work with modern JavaScript.
|
|
23
|
-
- **Integrated Dev Server** – Run your package with Vite and Express.
|
|
24
|
-
- **Efficient Build System** – Generate optimized ESM and CJS outputs.
|
|
25
|
-
- **One-Command Publish** – Deploy your package to npm effortlessly.
|
|
26
|
-
---
|
|
27
|
-
|
|
28
|
-
## 📜 CLI Commands
|
|
29
|
-
|
|
30
|
-
### ✨ `makepack create` – Scaffold a New Project
|
|
31
|
-
Quickly initialize a structured package with the following setup:
|
|
32
|
-
|
|
33
|
-
```
|
|
34
|
-
src/index.ts or tsx or js or jsx
|
|
35
|
-
.gitignore
|
|
36
|
-
package.json
|
|
37
|
-
README.md
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
Run:
|
|
41
|
-
```sh
|
|
42
|
-
makepack create
|
|
43
|
-
```
|
|
44
|
-
Follow the interactive prompts to configure your project.
|
|
45
|
-
|
|
46
|
-
### 🚀 `makepack start` – Launch the Development Server
|
|
47
|
-
Run a Vite + Express server to develop and test your package in real-time.
|
|
48
|
-
|
|
49
|
-
```sh
|
|
50
|
-
makepack start
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
### 🏗️ `makepack build` – Compile Your Package
|
|
54
|
-
Builds and optimizes your package into the `build` directory.
|
|
55
|
-
|
|
56
|
-
```sh
|
|
57
|
-
makepack build
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
### 📦 `makepack publish` – Deploy to NPM
|
|
61
|
-
Publish your package to the npm registry in one command.
|
|
62
|
-
|
|
63
|
-
```sh
|
|
64
|
-
makepack publish
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
---
|
|
68
|
-
|
|
69
|
-
## ⚙️ Configuration
|
|
70
|
-
|
|
71
|
-
Customize your project by creating a `makepack.js` file in the root directory. This file allows full control over the build and dev environment.
|
|
72
|
-
|
|
73
|
-
### 🔧 Default Configuration
|
|
74
|
-
|
|
75
|
-
```js
|
|
76
|
-
module.exports = (prevConfig) => ({
|
|
77
|
-
build: {
|
|
78
|
-
outdir: "build",
|
|
79
|
-
types: true,
|
|
80
|
-
formatPackageJson: (p) => p,
|
|
81
|
-
configs: [
|
|
82
|
-
{
|
|
83
|
-
entryPoints: "src/**/*.{tsx,ts,js,jsx}",
|
|
84
|
-
outdir: "esm",
|
|
85
|
-
format: "esm",
|
|
86
|
-
sourcemap: true,
|
|
87
|
-
jsx: 'automatic',
|
|
88
|
-
loader: {
|
|
89
|
-
'.ts': 'ts',
|
|
90
|
-
'.tsx': 'tsx'
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
entryPoints: "src/**/*.{tsx,ts,js,jsx}",
|
|
95
|
-
outdir: "",
|
|
96
|
-
format: "cjs",
|
|
97
|
-
sourcemap: true,
|
|
98
|
-
jsx: 'automatic',
|
|
99
|
-
loader: {
|
|
100
|
-
'.ts': 'ts',
|
|
101
|
-
'.tsx': 'tsx'
|
|
102
|
-
},
|
|
103
|
-
}
|
|
104
|
-
]
|
|
105
|
-
},
|
|
106
|
-
start: {
|
|
107
|
-
port: 5000,
|
|
108
|
-
entry: "App.tsx",
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
---
|
|
114
|
-
|
|
115
|
-
## 📜 License
|
|
116
|
-
|
|
117
|
-
`makepack` is released under the **MIT License**, allowing free usage in both open-source and commercial projects.
|
|
118
|
-
|
|
119
|
-
---
|
|
120
|
-
|
|
121
|
-
🚀 **Start building your next NPM package with `makepack` today!**
|
|
122
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://github.com/devnax/makepack" rel="noopener" target="_blank"><img src="https://raw.githubusercontent.com/devnax/makepack/main/logo.png" alt="Makepack logo"></a>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">Makepack</h1>
|
|
6
|
+
|
|
7
|
+
**MakePack** is a command-line interface (CLI) tool that helps you to quickly set up, build, and manage JavaScript, TypeScript, React, and React-TypeScript libraries for use in npm projects. With just a few simple commands, you can generate your own libraries, start a development server, or build and publish your project to the npm repository.
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## 📥 Installation
|
|
11
|
+
|
|
12
|
+
Install `makepack` globally to get started:
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
npm install -g makepack
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## 🎯 Why Choose makepack?
|
|
21
|
+
- **Zero-Config Setup** – Instantly scaffold a structured project.
|
|
22
|
+
- **TypeScript Support** – Seamlessly work with modern JavaScript.
|
|
23
|
+
- **Integrated Dev Server** – Run your package with Vite and Express.
|
|
24
|
+
- **Efficient Build System** – Generate optimized ESM and CJS outputs.
|
|
25
|
+
- **One-Command Publish** – Deploy your package to npm effortlessly.
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 📜 CLI Commands
|
|
29
|
+
|
|
30
|
+
### ✨ `makepack create` – Scaffold a New Project
|
|
31
|
+
Quickly initialize a structured package with the following setup:
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
src/index.ts or tsx or js or jsx
|
|
35
|
+
.gitignore
|
|
36
|
+
package.json
|
|
37
|
+
README.md
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Run:
|
|
41
|
+
```sh
|
|
42
|
+
makepack create
|
|
43
|
+
```
|
|
44
|
+
Follow the interactive prompts to configure your project.
|
|
45
|
+
|
|
46
|
+
### 🚀 `makepack start` – Launch the Development Server
|
|
47
|
+
Run a Vite + Express server to develop and test your package in real-time.
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
makepack start
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 🏗️ `makepack build` – Compile Your Package
|
|
54
|
+
Builds and optimizes your package into the `build` directory.
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
makepack build
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### 📦 `makepack publish` – Deploy to NPM
|
|
61
|
+
Publish your package to the npm registry in one command.
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
makepack publish
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## ⚙️ Configuration
|
|
70
|
+
|
|
71
|
+
Customize your project by creating a `makepack.js` file in the root directory. This file allows full control over the build and dev environment.
|
|
72
|
+
|
|
73
|
+
### 🔧 Default Configuration
|
|
74
|
+
|
|
75
|
+
```js
|
|
76
|
+
module.exports = (prevConfig) => ({
|
|
77
|
+
build: {
|
|
78
|
+
outdir: "build",
|
|
79
|
+
types: true,
|
|
80
|
+
formatPackageJson: (p) => p,
|
|
81
|
+
configs: [
|
|
82
|
+
{
|
|
83
|
+
entryPoints: "src/**/*.{tsx,ts,js,jsx}",
|
|
84
|
+
outdir: "esm",
|
|
85
|
+
format: "esm",
|
|
86
|
+
sourcemap: true,
|
|
87
|
+
jsx: 'automatic',
|
|
88
|
+
loader: {
|
|
89
|
+
'.ts': 'ts',
|
|
90
|
+
'.tsx': 'tsx'
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
entryPoints: "src/**/*.{tsx,ts,js,jsx}",
|
|
95
|
+
outdir: "",
|
|
96
|
+
format: "cjs",
|
|
97
|
+
sourcemap: true,
|
|
98
|
+
jsx: 'automatic',
|
|
99
|
+
loader: {
|
|
100
|
+
'.ts': 'ts',
|
|
101
|
+
'.tsx': 'tsx'
|
|
102
|
+
},
|
|
103
|
+
}
|
|
104
|
+
]
|
|
105
|
+
},
|
|
106
|
+
start: {
|
|
107
|
+
port: 5000,
|
|
108
|
+
entry: "App.tsx",
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## 📜 License
|
|
116
|
+
|
|
117
|
+
`makepack` is released under the **MIT License**, allowing free usage in both open-source and commercial projects.
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
🚀 **Start building your next NPM package with `makepack` today!**
|
|
122
|
+
|
package/package.json
CHANGED
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "makepack",
|
|
3
|
-
"version": "1.7.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"description": "A CLI tool to create, build, and manage JavaScript, TypeScript, React, and React-TypeScript libraries for npm projects.",
|
|
6
|
-
"categories": [
|
|
7
|
-
"Other"
|
|
8
|
-
],
|
|
9
|
-
"author": {
|
|
10
|
-
"name": "Devnax",
|
|
11
|
-
"email": "devnaxrul@gmail.com"
|
|
12
|
-
},
|
|
13
|
-
"bin": "./src/index.js",
|
|
14
|
-
"repository": {
|
|
15
|
-
"type": "git",
|
|
16
|
-
"url": "https://github.com/devnax/makepack"
|
|
17
|
-
},
|
|
18
|
-
"bugs": {
|
|
19
|
-
"url": "https://github.com/devnax/makepack/issues"
|
|
20
|
-
},
|
|
21
|
-
"homepage": "https://github.com/devnax/makepack#readme",
|
|
22
|
-
"scripts": {
|
|
23
|
-
"start": "node ./src/index.js start --port 3000",
|
|
24
|
-
"create": "node ./src/index.js create",
|
|
25
|
-
"build": "node ./src/index.js build"
|
|
26
|
-
},
|
|
27
|
-
"dependencies": {
|
|
28
|
-
"@rollup/plugin-commonjs": "^28.0.5",
|
|
29
|
-
"@rollup/plugin-json": "^6.1.0",
|
|
30
|
-
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
31
|
-
"@rollup/plugin-terser": "^0.4.4",
|
|
32
|
-
"@rollup/plugin-typescript": "^12.1.2",
|
|
33
|
-
"@types/fs-extra": "^11.0.4",
|
|
34
|
-
"chokidar": "^4.0.3",
|
|
35
|
-
"commander": "^12.1.0",
|
|
36
|
-
"esbuild": "^0.25.5",
|
|
37
|
-
"express": "^4.21.1",
|
|
38
|
-
"fs-extra": "^11.2.0",
|
|
39
|
-
"inquirer": "^12.1.0",
|
|
40
|
-
"lodash.debounce": "^4.0.8",
|
|
41
|
-
"madge": "^8.0.0",
|
|
42
|
-
"ora": "^8.1.1",
|
|
43
|
-
"react": "^19.1.0",
|
|
44
|
-
"react-dom": "^19.0.0",
|
|
45
|
-
"rollup": "^4.43.0",
|
|
46
|
-
"rollup-plugin-dts": "^6.2.1",
|
|
47
|
-
"tslib": "^2.8.1",
|
|
48
|
-
"vite": "^6.0.2"
|
|
49
|
-
},
|
|
50
|
-
"keywords": [
|
|
51
|
-
"CLI",
|
|
52
|
-
"npm",
|
|
53
|
-
"library",
|
|
54
|
-
"JavaScript",
|
|
55
|
-
"TypeScript",
|
|
56
|
-
"React",
|
|
57
|
-
"npm-package"
|
|
58
|
-
],
|
|
59
|
-
"devDependencies": {
|
|
60
|
-
"@types/react": "^19.1.8",
|
|
61
|
-
"typescript": "^5.8.3"
|
|
62
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "makepack",
|
|
3
|
+
"version": "1.7.12",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "A CLI tool to create, build, and manage JavaScript, TypeScript, React, and React-TypeScript libraries for npm projects.",
|
|
6
|
+
"categories": [
|
|
7
|
+
"Other"
|
|
8
|
+
],
|
|
9
|
+
"author": {
|
|
10
|
+
"name": "Devnax",
|
|
11
|
+
"email": "devnaxrul@gmail.com"
|
|
12
|
+
},
|
|
13
|
+
"bin": "./src/index.js",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/devnax/makepack"
|
|
17
|
+
},
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/devnax/makepack/issues"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://github.com/devnax/makepack#readme",
|
|
22
|
+
"scripts": {
|
|
23
|
+
"start": "node ./src/index.js start --port 3000",
|
|
24
|
+
"create": "node ./src/index.js create",
|
|
25
|
+
"build": "node ./src/index.js build"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@rollup/plugin-commonjs": "^28.0.5",
|
|
29
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
30
|
+
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
31
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
32
|
+
"@rollup/plugin-typescript": "^12.1.2",
|
|
33
|
+
"@types/fs-extra": "^11.0.4",
|
|
34
|
+
"chokidar": "^4.0.3",
|
|
35
|
+
"commander": "^12.1.0",
|
|
36
|
+
"esbuild": "^0.25.5",
|
|
37
|
+
"express": "^4.21.1",
|
|
38
|
+
"fs-extra": "^11.2.0",
|
|
39
|
+
"inquirer": "^12.1.0",
|
|
40
|
+
"lodash.debounce": "^4.0.8",
|
|
41
|
+
"madge": "^8.0.0",
|
|
42
|
+
"ora": "^8.1.1",
|
|
43
|
+
"react": "^19.1.0",
|
|
44
|
+
"react-dom": "^19.0.0",
|
|
45
|
+
"rollup": "^4.43.0",
|
|
46
|
+
"rollup-plugin-dts": "^6.2.1",
|
|
47
|
+
"tslib": "^2.8.1",
|
|
48
|
+
"vite": "^6.0.2"
|
|
49
|
+
},
|
|
50
|
+
"keywords": [
|
|
51
|
+
"CLI",
|
|
52
|
+
"npm",
|
|
53
|
+
"library",
|
|
54
|
+
"JavaScript",
|
|
55
|
+
"TypeScript",
|
|
56
|
+
"React",
|
|
57
|
+
"npm-package"
|
|
58
|
+
],
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@types/react": "^19.1.8",
|
|
61
|
+
"typescript": "^5.8.3"
|
|
62
|
+
}
|
|
63
63
|
}
|
|
@@ -1,113 +1,115 @@
|
|
|
1
|
-
import { rollup } from "rollup";
|
|
2
|
-
import resolve from "@rollup/plugin-node-resolve";
|
|
3
|
-
import commonjs from "@rollup/plugin-commonjs";
|
|
4
|
-
import typescript from "@rollup/plugin-typescript";
|
|
5
|
-
import path from "path";
|
|
6
|
-
import dts from "rollup-plugin-dts";
|
|
7
|
-
import json from '@rollup/plugin-json';
|
|
8
|
-
import terser from "@rollup/plugin-terser";
|
|
9
|
-
|
|
10
|
-
async function
|
|
11
|
-
const isTs = args.entry.endsWith('.ts') || args.entry.endsWith('.tsx')
|
|
12
|
-
|
|
13
|
-
const config = {
|
|
14
|
-
input: [args.entry],
|
|
15
|
-
external: (id) => {
|
|
16
|
-
return !id.startsWith('.') && !id.startsWith('/') && !/^[A-Za-z]:\\/.test(id);
|
|
17
|
-
},
|
|
18
|
-
plugins: [
|
|
19
|
-
json(),
|
|
20
|
-
resolve({
|
|
21
|
-
extensions: ['.js', '.ts', '.jsx', '.tsx', '.json', '.mjs', '.cjs'],
|
|
22
|
-
browser: false
|
|
23
|
-
}),
|
|
24
|
-
commonjs(),
|
|
25
|
-
|
|
26
|
-
tsconfig: false,
|
|
27
|
-
target: "ES2017",
|
|
28
|
-
module: "ESNext",
|
|
29
|
-
jsx: "react-jsx",
|
|
30
|
-
moduleResolution: "node", // ✅ Correct and lowercase
|
|
31
|
-
esModuleInterop: true,
|
|
32
|
-
skipLibCheck: false,
|
|
33
|
-
strict: true,
|
|
34
|
-
importHelpers: true,
|
|
35
|
-
forceConsistentCasingInFileNames: true,
|
|
36
|
-
declaration: false,
|
|
37
|
-
emitDeclarationOnly: false
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
} else if (args.format === "
|
|
74
|
-
outputOptions = [
|
|
75
|
-
} else if (args.format === "
|
|
76
|
-
outputOptions = [
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
1
|
+
import { rollup } from "rollup";
|
|
2
|
+
import resolve from "@rollup/plugin-node-resolve";
|
|
3
|
+
import commonjs from "@rollup/plugin-commonjs";
|
|
4
|
+
import typescript from "@rollup/plugin-typescript";
|
|
5
|
+
import path from "path";
|
|
6
|
+
import dts from "rollup-plugin-dts";
|
|
7
|
+
import json from '@rollup/plugin-json';
|
|
8
|
+
import terser from "@rollup/plugin-terser";
|
|
9
|
+
|
|
10
|
+
async function bundler(args, spinner) {
|
|
11
|
+
const isTs = args.entry.endsWith('.ts') || args.entry.endsWith('.tsx')
|
|
12
|
+
|
|
13
|
+
const config = {
|
|
14
|
+
input: [args.entry],
|
|
15
|
+
external: (id) => {
|
|
16
|
+
return !id.startsWith('.') && !id.startsWith('/') && !/^[A-Za-z]:\\/.test(id);
|
|
17
|
+
},
|
|
18
|
+
plugins: [
|
|
19
|
+
json(),
|
|
20
|
+
resolve({
|
|
21
|
+
extensions: ['.js', '.ts', '.jsx', '.tsx', '.json', '.mjs', '.cjs'],
|
|
22
|
+
browser: false
|
|
23
|
+
}),
|
|
24
|
+
commonjs(),
|
|
25
|
+
typescript({
|
|
26
|
+
tsconfig: false,
|
|
27
|
+
target: "ES2017",
|
|
28
|
+
module: "ESNext",
|
|
29
|
+
jsx: "react-jsx",
|
|
30
|
+
moduleResolution: "node", // ✅ Correct and lowercase
|
|
31
|
+
esModuleInterop: true,
|
|
32
|
+
skipLibCheck: false,
|
|
33
|
+
strict: true,
|
|
34
|
+
importHelpers: true,
|
|
35
|
+
forceConsistentCasingInFileNames: true,
|
|
36
|
+
declaration: false,
|
|
37
|
+
emitDeclarationOnly: false,
|
|
38
|
+
rootDir: path.resolve(process.cwd(), args.rootdir),
|
|
39
|
+
}),
|
|
40
|
+
args.minify ? terser() : null,
|
|
41
|
+
]
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const bundle = await rollup(config);
|
|
45
|
+
const esm = {
|
|
46
|
+
dir: args.outdir,
|
|
47
|
+
format: "esm",
|
|
48
|
+
sourcemap: args.sourcemap,
|
|
49
|
+
compact: true,
|
|
50
|
+
strict: true,
|
|
51
|
+
exports: "named"
|
|
52
|
+
};
|
|
53
|
+
if (!args.bundle) {
|
|
54
|
+
esm.preserveModules = true
|
|
55
|
+
esm.preserveModulesRoot = args.rootdir
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
let cjs = {
|
|
59
|
+
...esm,
|
|
60
|
+
dir: args.outdir,
|
|
61
|
+
format: "cjs",
|
|
62
|
+
dynamicImportInCjs: true,
|
|
63
|
+
esModule: true,
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
let outputOptions = []
|
|
67
|
+
|
|
68
|
+
if (args.format === "both") {
|
|
69
|
+
outputOptions = [
|
|
70
|
+
{ ...esm, entryFileNames: '[name].mjs' },
|
|
71
|
+
cjs,
|
|
72
|
+
]
|
|
73
|
+
} else if (args.format === "esm") {
|
|
74
|
+
outputOptions = [esm];
|
|
75
|
+
} else if (args.format === "cjs") {
|
|
76
|
+
outputOptions = [cjs];
|
|
77
|
+
} else if (args.format === "iife") {
|
|
78
|
+
outputOptions = [{
|
|
79
|
+
...esm,
|
|
80
|
+
format: "iife",
|
|
81
|
+
name: args.name || path.basename(args.entry, path.extname(args.entry)),
|
|
82
|
+
entryFileNames: '[name].js',
|
|
83
|
+
}];
|
|
84
|
+
} else if (args.format === "umd") {
|
|
85
|
+
outputOptions = [{
|
|
86
|
+
...esm,
|
|
87
|
+
format: "umd",
|
|
88
|
+
name: args.name || path.basename(args.entry, path.extname(args.entry)),
|
|
89
|
+
entryFileNames: '[name].js',
|
|
90
|
+
}];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
for (const output of outputOptions) {
|
|
94
|
+
await bundle.write(output);
|
|
95
|
+
}
|
|
96
|
+
await bundle.close();
|
|
97
|
+
|
|
98
|
+
// If TypeScript declaration files are requested, generate them
|
|
99
|
+
if (isTs && args.declaration) {
|
|
100
|
+
spinner.text = "Generating TypeScript declarations..."
|
|
101
|
+
const bundlets = await rollup({
|
|
102
|
+
...config,
|
|
103
|
+
plugins: [dts()],
|
|
104
|
+
});
|
|
105
|
+
await bundlets.write({
|
|
106
|
+
format: "esm",
|
|
107
|
+
preserveModules: true,
|
|
108
|
+
preserveModulesRoot: args.rootdir,
|
|
109
|
+
dir: path.join(args.outdir),
|
|
110
|
+
});
|
|
111
|
+
await bundlets.close();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export default bundler;
|