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 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.10",
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 bind(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
- isTs ? 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
- }) : null,
39
- args.minify ? terser() : null,
40
- ]
41
- };
42
-
43
- const bundle = await rollup(config);
44
- const esm = {
45
- dir: args.outdir,
46
- format: "esm",
47
- sourcemap: args.sourcemap,
48
- compact: true,
49
- strict: true
50
- };
51
- if (!args.bundle) {
52
- esm.preserveModules = true
53
- esm.preserveModulesRoot = args.rootdir
54
- }
55
-
56
- let cjs = {
57
- ...esm,
58
- dir: args.outdir,
59
- format: "cjs",
60
- dynamicImportInCjs: true,
61
- esModule: true,
62
- }
63
-
64
- let outputOptions = []
65
-
66
- if (args.format === "both") {
67
- outputOptions = [
68
- { ...esm, entryFileNames: '[name].mjs' },
69
- cjs,
70
- ]
71
- } else if (args.format === "esm") {
72
- outputOptions = [esm];
73
- } else if (args.format === "cjs") {
74
- outputOptions = [cjs];
75
- } else if (args.format === "iife") {
76
- outputOptions = [{
77
- ...esm,
78
- format: "iife",
79
- name: args.name || path.basename(args.entry, path.extname(args.entry)),
80
- entryFileNames: '[name].js',
81
- }];
82
- } else if (args.format === "umd") {
83
- outputOptions = [{
84
- ...esm,
85
- format: "umd",
86
- name: args.name || path.basename(args.entry, path.extname(args.entry)),
87
- entryFileNames: '[name].js',
88
- }];
89
- }
90
-
91
- for (const output of outputOptions) {
92
- await bundle.write(output);
93
- }
94
- await bundle.close();
95
-
96
- // If TypeScript declaration files are requested, generate them
97
- if (isTs && args.declaration) {
98
- spinner.text = "Generating TypeScript declarations..."
99
- const bundlets = await rollup({
100
- ...config,
101
- plugins: [dts()],
102
- });
103
- await bundlets.write({
104
- format: "esm",
105
- preserveModules: true,
106
- preserveModulesRoot: args.rootdir,
107
- dir: path.join(args.outdir),
108
- });
109
- await bundlets.close();
110
- }
111
- }
112
-
113
- export default bind;
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;