create-packkit 0.3.0 → 0.3.1
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 +1 -1
- package/package.json +1 -1
- package/src/cli/args.js +2 -0
- package/src/cli/wizard.js +3 -0
- package/src/core/features/bundler.js +11 -5
- package/src/core/options.js +5 -0
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ No install needed: **[danmat.github.io/create-packkit](https://danmat.github.io/
|
|
|
36
36
|
| **Module format** | ESM · CJS · dual (proper `exports` map) |
|
|
37
37
|
| **Target** | Library · CLI tool · both |
|
|
38
38
|
| **Framework** | None · **React** (component library — JSX, peer deps, jsdom tests) |
|
|
39
|
-
| **Bundler** | tsup · tsdown · unbuild · rollup · none (tsc) |
|
|
39
|
+
| **Bundler** | tsup · tsdown · unbuild · rollup · none (tsc) · optional **minify** |
|
|
40
40
|
| **Tests** | Vitest · Jest · node:test · none (+ coverage) |
|
|
41
41
|
| **Lint/format** | ESLint + Prettier · Biome · oxlint · none |
|
|
42
42
|
| **Git hooks** | simple-git-hooks · husky + lint-staged · lefthook · none |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-packkit",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Highly configurable scaffolder for modern npm packages and CLIs — pick your stack (TS/JS, bundler, tests, linter, CI, releases) from a CLI or a web configurator.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/src/cli/args.js
CHANGED
|
@@ -29,6 +29,7 @@ export function parseCliArgs(argv) {
|
|
|
29
29
|
here: { type: 'boolean' },
|
|
30
30
|
'no-install': { type: 'boolean' },
|
|
31
31
|
'no-git': { type: 'boolean' },
|
|
32
|
+
minify: { type: 'boolean' },
|
|
32
33
|
target: { type: 'string', multiple: true },
|
|
33
34
|
help: { type: 'boolean', short: 'h' },
|
|
34
35
|
version: { type: 'boolean', short: 'v' },
|
|
@@ -47,6 +48,7 @@ export function parseCliArgs(argv) {
|
|
|
47
48
|
if (values[flag] != null) overrides[key] = values[flag];
|
|
48
49
|
}
|
|
49
50
|
if (values.target) overrides.target = values.target;
|
|
51
|
+
if (values.minify) overrides.minify = true;
|
|
50
52
|
if (name) overrides.name = name;
|
|
51
53
|
|
|
52
54
|
return {
|
package/src/cli/wizard.js
CHANGED
|
@@ -32,6 +32,9 @@ export async function runWizard(seed = {}) {
|
|
|
32
32
|
cfg.moduleFormat = bail(await p.select({ message: 'Module format', options: asOptions('moduleFormat'), initialValue: OPTIONS.moduleFormat.default }));
|
|
33
33
|
cfg.packageManager = bail(await p.select({ message: 'Package manager', options: asOptions('packageManager'), initialValue: OPTIONS.packageManager.default }));
|
|
34
34
|
cfg.bundler = bail(await p.select({ message: 'Build / bundler', options: asOptions('bundler'), initialValue: OPTIONS.bundler.default }));
|
|
35
|
+
if (cfg.bundler !== 'none') {
|
|
36
|
+
cfg.minify = bail(await p.confirm({ message: 'Minify the build output?', initialValue: false }));
|
|
37
|
+
}
|
|
35
38
|
cfg.test = bail(await p.select({ message: 'Test runner', options: asOptions('test'), initialValue: OPTIONS.test.default }));
|
|
36
39
|
cfg.lint = bail(await p.select({ message: 'Lint / format', options: asOptions('lint'), initialValue: OPTIONS.lint.default }));
|
|
37
40
|
cfg.gitHooks = bail(await p.select({ message: 'Git hooks', options: asOptions('gitHooks'), initialValue: OPTIONS.gitHooks.default }));
|
|
@@ -55,6 +55,7 @@ export default {
|
|
|
55
55
|
pkg.devDependencies = {
|
|
56
56
|
rollup: '^4.0.0',
|
|
57
57
|
...(cfg.isTs ? { '@rollup/plugin-typescript': '^11.0.0', tslib: '^2.6.0' } : {}),
|
|
58
|
+
...(cfg.minify ? { '@rollup/plugin-terser': '^0.4.0' } : {}),
|
|
58
59
|
};
|
|
59
60
|
} else if (cfg.bundler === 'none' && cfg.isTs) {
|
|
60
61
|
// tsc-only build for TypeScript.
|
|
@@ -81,6 +82,7 @@ function tsupConfig(cfg, entries, formats, tool) {
|
|
|
81
82
|
`\tsourcemap: true,`,
|
|
82
83
|
`\tclean: true,`,
|
|
83
84
|
`\ttreeshake: true,`,
|
|
85
|
+
cfg.minify ? `\tminify: true,` : null,
|
|
84
86
|
`});`,
|
|
85
87
|
``,
|
|
86
88
|
].filter((l) => l !== null).join('\n');
|
|
@@ -94,7 +96,7 @@ function unbuildConfig(cfg) {
|
|
|
94
96
|
`\tentries: ['src/index'],`,
|
|
95
97
|
`\tdeclaration: ${cfg.isTs},`,
|
|
96
98
|
`\tclean: true,`,
|
|
97
|
-
`\trollup: { emitCJS: ${cfg.hasCjs} },`,
|
|
99
|
+
`\trollup: { emitCJS: ${cfg.hasCjs}${cfg.minify ? ', esbuild: { minify: true }' : ''} },`,
|
|
98
100
|
`});`,
|
|
99
101
|
``,
|
|
100
102
|
].join('\n');
|
|
@@ -104,14 +106,18 @@ function rollupConfig(cfg, formats) {
|
|
|
104
106
|
const out = formats
|
|
105
107
|
.map((f) => `\t\t{ file: 'dist/index.${f === 'cjs' ? 'cjs' : 'js'}', format: '${f}', sourcemap: true }`)
|
|
106
108
|
.join(',\n');
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
+
const imports = [
|
|
110
|
+
cfg.isTs ? `import typescript from '@rollup/plugin-typescript';` : null,
|
|
111
|
+
cfg.minify ? `import terser from '@rollup/plugin-terser';` : null,
|
|
112
|
+
].filter(Boolean);
|
|
113
|
+
const plugins = [cfg.isTs ? 'typescript()' : null, cfg.minify ? 'terser()' : null].filter(Boolean);
|
|
114
|
+
const pluginLine = plugins.length ? `\n\tplugins: [${plugins.join(', ')}],` : '';
|
|
109
115
|
return [
|
|
110
|
-
|
|
116
|
+
(imports.length ? imports.join('\n') + '\n' : '') + `export default {`,
|
|
111
117
|
`\tinput: 'src/index.${cfg.ext}',`,
|
|
112
118
|
`\toutput: [`,
|
|
113
119
|
out,
|
|
114
|
-
`\t],${
|
|
120
|
+
`\t],${pluginLine}`,
|
|
115
121
|
`};`,
|
|
116
122
|
``,
|
|
117
123
|
].join('\n');
|
package/src/core/options.js
CHANGED
|
@@ -71,6 +71,9 @@ export const OPTIONS = {
|
|
|
71
71
|
{ value: 'none', label: 'None (tsc / no build)' },
|
|
72
72
|
],
|
|
73
73
|
},
|
|
74
|
+
minify: {
|
|
75
|
+
group: 'build', type: 'boolean', label: 'Minify output (best for CLIs / browser bundles)', default: false,
|
|
76
|
+
},
|
|
74
77
|
|
|
75
78
|
// ---- testing ----
|
|
76
79
|
test: {
|
|
@@ -184,6 +187,8 @@ export function normalizeConfig(input = {}) {
|
|
|
184
187
|
if (!Array.isArray(cfg.target) || cfg.target.length === 0) cfg.target = ['library'];
|
|
185
188
|
if (!Array.isArray(cfg.workflows)) cfg.workflows = [];
|
|
186
189
|
|
|
190
|
+
// Minify needs a bundler.
|
|
191
|
+
if (cfg.bundler === 'none') cfg.minify = false;
|
|
187
192
|
// Coverage only makes sense with a test runner that supports it.
|
|
188
193
|
if (cfg.test === 'none' || cfg.test === 'node') cfg.coverage = false;
|
|
189
194
|
// Codecov workflow implies coverage.
|