quickbundle 0.2.1 → 0.4.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 +3 -1
- package/bin/bundler/bundler.d.ts +9 -0
- package/bin/bundler/bundler.js +49 -0
- package/bin/bundler/index.d.ts +3 -0
- package/bin/bundler/index.js +7 -0
- package/bin/bundler/metadata.d.ts +11 -0
- package/bin/bundler/metadata.js +26 -0
- package/bin/bundler/plugins.d.ts +3 -0
- package/bin/bundler/plugins.js +32 -0
- package/bin/bundler/typescript.d.ts +5 -0
- package/bin/bundler/typescript.js +56 -0
- package/bin/helpers.d.ts +5 -0
- package/bin/helpers.js +22 -0
- package/bin/index.d.ts +1 -1
- package/bin/index.js +1 -10
- package/bin/program/commands/build.d.ts +13 -0
- package/bin/program/commands/build.js +87 -0
- package/bin/program/commands/watch.d.ts +9 -0
- package/bin/program/commands/watch.js +56 -0
- package/bin/{commands/build.d.ts → program/index.d.ts} +0 -0
- package/bin/program/index.js +12 -0
- package/bin/test.d.ts +3 -0
- package/bin/test.js +10 -0
- package/bin/tsconfig.tsbuildinfo +1 -1085
- package/bin/types.d.ts +1 -0
- package/bin/{commands/watch.js → types.js} +0 -1
- package/package.json +72 -32
- package/bin/commands/build.js +0 -53
- package/bin/commands/watch.d.ts +0 -1
- package/bin/entities/bundler.d.ts +0 -10
- package/bin/entities/bundler.js +0 -186
- package/bin/entities/project.d.ts +0 -10
- package/bin/entities/project.js +0 -33
package/bin/types.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare type ModuleFormat = "esm" | "cjs";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quickbundle",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"bin": {
|
|
5
5
|
"quickbundle": "bin/index.js"
|
|
6
6
|
},
|
|
@@ -17,50 +17,37 @@
|
|
|
17
17
|
"url": "git@github.com:adbayb/quickbundle.git"
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
|
+
"main": "bin/index.js",
|
|
20
21
|
"scripts": {
|
|
21
|
-
"
|
|
22
|
+
"prepublishOnly": "yarn lint",
|
|
22
23
|
"prestart": "yarn build",
|
|
23
24
|
"start": "bin/index.js",
|
|
24
25
|
"clean": "rm -rf bin",
|
|
25
26
|
"build": "tsc && chmod +x bin/index.js",
|
|
26
27
|
"watch": "tsc -w",
|
|
27
|
-
"format": "prettier . --ignore-path .gitignore --
|
|
28
|
+
"format": "prettier . --ignore-path .gitignore --write",
|
|
28
29
|
"lint": "eslint . --ignore-path .gitignore --fix",
|
|
29
30
|
"release": "semantic-release"
|
|
30
31
|
},
|
|
31
32
|
"dependencies": {
|
|
32
|
-
"
|
|
33
|
-
"
|
|
33
|
+
"esbuild": "0.13.15",
|
|
34
|
+
"gzip-size": "6.0.0",
|
|
35
|
+
"termost": "0.2.1"
|
|
34
36
|
},
|
|
35
37
|
"devDependencies": {
|
|
36
|
-
"@adbayb/eslint-config": "0.
|
|
37
|
-
"@adbayb/prettier-config": "0.
|
|
38
|
-
"@adbayb/ts-config": "0.
|
|
39
|
-
"@commitlint/cli": "
|
|
40
|
-
"@commitlint/config-conventional": "
|
|
41
|
-
"@semantic-release/git": "
|
|
42
|
-
"@types/node": "
|
|
38
|
+
"@adbayb/eslint-config": "0.7.0",
|
|
39
|
+
"@adbayb/prettier-config": "0.7.0",
|
|
40
|
+
"@adbayb/ts-config": "0.7.0",
|
|
41
|
+
"@commitlint/cli": "15.0.0",
|
|
42
|
+
"@commitlint/config-conventional": "15.0.0",
|
|
43
|
+
"@semantic-release/git": "10.0.1",
|
|
44
|
+
"@types/node": "16.11.9",
|
|
45
|
+
"eslint": "7.32.0",
|
|
43
46
|
"husky": "4.3.8",
|
|
44
|
-
"lint-staged": "
|
|
45
|
-
"
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"branches": [
|
|
49
|
-
"main"
|
|
50
|
-
],
|
|
51
|
-
"ci": false,
|
|
52
|
-
"plugins": [
|
|
53
|
-
"@semantic-release/commit-analyzer",
|
|
54
|
-
"@semantic-release/release-notes-generator",
|
|
55
|
-
"@semantic-release/npm",
|
|
56
|
-
[
|
|
57
|
-
"@semantic-release/git",
|
|
58
|
-
{
|
|
59
|
-
"message": "chore(release): ${nextRelease.version}\n\n${nextRelease.notes}"
|
|
60
|
-
}
|
|
61
|
-
],
|
|
62
|
-
"@semantic-release/github"
|
|
63
|
-
]
|
|
47
|
+
"lint-staged": "12.1.2",
|
|
48
|
+
"prettier": "2.4.1",
|
|
49
|
+
"semantic-release": "18.0.0",
|
|
50
|
+
"typescript": "4.5.2"
|
|
64
51
|
},
|
|
65
52
|
"commitlint": {
|
|
66
53
|
"extends": [
|
|
@@ -84,5 +71,58 @@
|
|
|
84
71
|
"**/*.{json,md,mdx,html,css}": [
|
|
85
72
|
"yarn format"
|
|
86
73
|
]
|
|
74
|
+
},
|
|
75
|
+
"release": {
|
|
76
|
+
"branches": [
|
|
77
|
+
"main"
|
|
78
|
+
],
|
|
79
|
+
"ci": false,
|
|
80
|
+
"plugins": [
|
|
81
|
+
[
|
|
82
|
+
"@semantic-release/commit-analyzer",
|
|
83
|
+
{
|
|
84
|
+
"releaseRules": [
|
|
85
|
+
{
|
|
86
|
+
"breaking": true,
|
|
87
|
+
"release": "major"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"revert": true,
|
|
91
|
+
"release": "patch"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"type": "feat",
|
|
95
|
+
"release": "minor"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"type": "fix",
|
|
99
|
+
"release": "patch"
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"type": "perf",
|
|
103
|
+
"release": "patch"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"type": "refactor",
|
|
107
|
+
"release": "patch"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"type": "chore",
|
|
111
|
+
"scope": "deps",
|
|
112
|
+
"release": "patch"
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
],
|
|
117
|
+
"@semantic-release/release-notes-generator",
|
|
118
|
+
"@semantic-release/npm",
|
|
119
|
+
[
|
|
120
|
+
"@semantic-release/git",
|
|
121
|
+
{
|
|
122
|
+
"message": "chore(release): ${nextRelease.version}\n\n${nextRelease.notes}"
|
|
123
|
+
}
|
|
124
|
+
],
|
|
125
|
+
"@semantic-release/github"
|
|
126
|
+
]
|
|
87
127
|
}
|
|
88
128
|
}
|
package/bin/commands/build.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter =
|
|
3
|
-
(this && this.__awaiter) ||
|
|
4
|
-
function (thisArg, _arguments, P, generator) {
|
|
5
|
-
function adopt(value) {
|
|
6
|
-
return value instanceof P
|
|
7
|
-
? value
|
|
8
|
-
: new P(function (resolve) {
|
|
9
|
-
resolve(value);
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
13
|
-
function fulfilled(value) {
|
|
14
|
-
try {
|
|
15
|
-
step(generator.next(value));
|
|
16
|
-
} catch (e) {
|
|
17
|
-
reject(e);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
function rejected(value) {
|
|
21
|
-
try {
|
|
22
|
-
step(generator["throw"](value));
|
|
23
|
-
} catch (e) {
|
|
24
|
-
reject(e);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
function step(result) {
|
|
28
|
-
result.done
|
|
29
|
-
? resolve(result.value)
|
|
30
|
-
: adopt(result.value).then(fulfilled, rejected);
|
|
31
|
-
}
|
|
32
|
-
step(
|
|
33
|
-
(generator = generator.apply(thisArg, _arguments || [])).next()
|
|
34
|
-
);
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
const terminal_kit_1 = require("@adbayb/terminal-kit");
|
|
39
|
-
const bundler_1 = require("../entities/bundler");
|
|
40
|
-
const project_1 = require("../entities/project");
|
|
41
|
-
const main = () =>
|
|
42
|
-
__awaiter(void 0, void 0, void 0, function* () {
|
|
43
|
-
const project = project_1.createProject();
|
|
44
|
-
const bundle = yield bundler_1.createBundler(project);
|
|
45
|
-
const formats = ["cjs", "esm"];
|
|
46
|
-
for (const format of formats) {
|
|
47
|
-
yield terminal_kit_1.run(
|
|
48
|
-
`Building ${format} 👷♂️`,
|
|
49
|
-
bundle(format, false)
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
main();
|
package/bin/commands/watch.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Project } from "./project";
|
|
2
|
-
export declare type BundleFormat = "esm" | "cjs";
|
|
3
|
-
export declare const createBundler: (
|
|
4
|
-
project: Project
|
|
5
|
-
) => Promise<
|
|
6
|
-
(
|
|
7
|
-
format: BundleFormat,
|
|
8
|
-
isProduction?: boolean | undefined
|
|
9
|
-
) => Promise<import("esbuild").BuildResult>
|
|
10
|
-
>;
|
package/bin/entities/bundler.js
DELETED
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding =
|
|
3
|
-
(this && this.__createBinding) ||
|
|
4
|
-
(Object.create
|
|
5
|
-
? function (o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
Object.defineProperty(o, k2, {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function () {
|
|
10
|
-
return m[k];
|
|
11
|
-
},
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
: function (o, m, k, k2) {
|
|
15
|
-
if (k2 === undefined) k2 = k;
|
|
16
|
-
o[k2] = m[k];
|
|
17
|
-
});
|
|
18
|
-
var __setModuleDefault =
|
|
19
|
-
(this && this.__setModuleDefault) ||
|
|
20
|
-
(Object.create
|
|
21
|
-
? function (o, v) {
|
|
22
|
-
Object.defineProperty(o, "default", {
|
|
23
|
-
enumerable: true,
|
|
24
|
-
value: v,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
: function (o, v) {
|
|
28
|
-
o["default"] = v;
|
|
29
|
-
});
|
|
30
|
-
var __importStar =
|
|
31
|
-
(this && this.__importStar) ||
|
|
32
|
-
function (mod) {
|
|
33
|
-
if (mod && mod.__esModule) return mod;
|
|
34
|
-
var result = {};
|
|
35
|
-
if (mod != null)
|
|
36
|
-
for (var k in mod)
|
|
37
|
-
if (
|
|
38
|
-
k !== "default" &&
|
|
39
|
-
Object.prototype.hasOwnProperty.call(mod, k)
|
|
40
|
-
)
|
|
41
|
-
__createBinding(result, mod, k);
|
|
42
|
-
__setModuleDefault(result, mod);
|
|
43
|
-
return result;
|
|
44
|
-
};
|
|
45
|
-
var __awaiter =
|
|
46
|
-
(this && this.__awaiter) ||
|
|
47
|
-
function (thisArg, _arguments, P, generator) {
|
|
48
|
-
function adopt(value) {
|
|
49
|
-
return value instanceof P
|
|
50
|
-
? value
|
|
51
|
-
: new P(function (resolve) {
|
|
52
|
-
resolve(value);
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
56
|
-
function fulfilled(value) {
|
|
57
|
-
try {
|
|
58
|
-
step(generator.next(value));
|
|
59
|
-
} catch (e) {
|
|
60
|
-
reject(e);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
function rejected(value) {
|
|
64
|
-
try {
|
|
65
|
-
step(generator["throw"](value));
|
|
66
|
-
} catch (e) {
|
|
67
|
-
reject(e);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
function step(result) {
|
|
71
|
-
result.done
|
|
72
|
-
? resolve(result.value)
|
|
73
|
-
: adopt(result.value).then(fulfilled, rejected);
|
|
74
|
-
}
|
|
75
|
-
step(
|
|
76
|
-
(generator = generator.apply(thisArg, _arguments || [])).next()
|
|
77
|
-
);
|
|
78
|
-
});
|
|
79
|
-
};
|
|
80
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
81
|
-
exports.createBundler = void 0;
|
|
82
|
-
const path_1 = require("path");
|
|
83
|
-
const esbuild_1 = require("esbuild");
|
|
84
|
-
const constants_1 = require("../constants");
|
|
85
|
-
const resolveModulePath = (path) => {
|
|
86
|
-
try {
|
|
87
|
-
return Boolean(require.resolve(path));
|
|
88
|
-
} catch (error) {
|
|
89
|
-
return false;
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
const getTypeScriptOptions = () =>
|
|
93
|
-
__awaiter(void 0, void 0, void 0, function* () {
|
|
94
|
-
var _a;
|
|
95
|
-
try {
|
|
96
|
-
const ts = yield Promise.resolve().then(() =>
|
|
97
|
-
__importStar(require("typescript"))
|
|
98
|
-
);
|
|
99
|
-
const { jsx, target } = ts.parseJsonConfigFileContent(
|
|
100
|
-
require(path_1.resolve(constants_1.CWD, "tsconfig.json")),
|
|
101
|
-
ts.sys,
|
|
102
|
-
constants_1.CWD
|
|
103
|
-
).options;
|
|
104
|
-
const esbuildTarget =
|
|
105
|
-
!target ||
|
|
106
|
-
[ts.ScriptTarget.ESNext, ts.ScriptTarget.Latest].includes(
|
|
107
|
-
target
|
|
108
|
-
)
|
|
109
|
-
? "esnext"
|
|
110
|
-
: (_a = ts.ScriptTarget[target]) === null || _a === void 0
|
|
111
|
-
? void 0
|
|
112
|
-
: _a.toLowerCase();
|
|
113
|
-
return {
|
|
114
|
-
target: esbuildTarget,
|
|
115
|
-
hasJsxRuntime:
|
|
116
|
-
jsx !== undefined &&
|
|
117
|
-
[
|
|
118
|
-
ts.JsxEmit["ReactJSX"],
|
|
119
|
-
ts.JsxEmit["ReactJSXDev"],
|
|
120
|
-
].includes(jsx),
|
|
121
|
-
};
|
|
122
|
-
} catch (error) {
|
|
123
|
-
return null;
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
const createBundler = (project) =>
|
|
127
|
-
__awaiter(void 0, void 0, void 0, function* () {
|
|
128
|
-
const tsOptions = yield getTypeScriptOptions();
|
|
129
|
-
return (format, isProduction) => {
|
|
130
|
-
return esbuild_1.build({
|
|
131
|
-
absWorkingDir: constants_1.CWD,
|
|
132
|
-
bundle: true,
|
|
133
|
-
define: {
|
|
134
|
-
"process.env.NODE_ENV": isProduction
|
|
135
|
-
? '"production"'
|
|
136
|
-
: '"development"',
|
|
137
|
-
},
|
|
138
|
-
entryPoints: [project.source],
|
|
139
|
-
external: project.externalDependencies,
|
|
140
|
-
format,
|
|
141
|
-
minify: isProduction,
|
|
142
|
-
outfile: project.destination[format],
|
|
143
|
-
sourcemap: !isProduction,
|
|
144
|
-
target:
|
|
145
|
-
(tsOptions === null || tsOptions === void 0
|
|
146
|
-
? void 0
|
|
147
|
-
: tsOptions.target) || "esnext",
|
|
148
|
-
plugins: [
|
|
149
|
-
{
|
|
150
|
-
name: "jsx-runtime",
|
|
151
|
-
setup(build) {
|
|
152
|
-
const fs = require("fs");
|
|
153
|
-
build.onLoad({ filter: /\.(j|t)sx$/ }, ({ path }) =>
|
|
154
|
-
__awaiter(this, void 0, void 0, function* () {
|
|
155
|
-
const module = ["preact", "react"].find(
|
|
156
|
-
project.hasModule
|
|
157
|
-
);
|
|
158
|
-
if (
|
|
159
|
-
!module ||
|
|
160
|
-
!resolveModulePath(
|
|
161
|
-
`${module}/jsx-runtime`
|
|
162
|
-
) ||
|
|
163
|
-
(tsOptions === null ||
|
|
164
|
-
tsOptions === void 0
|
|
165
|
-
? void 0
|
|
166
|
-
: tsOptions.hasJsxRuntime) === false
|
|
167
|
-
) {
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
const content = yield fs.promises.readFile(
|
|
171
|
-
path,
|
|
172
|
-
"utf8"
|
|
173
|
-
);
|
|
174
|
-
return {
|
|
175
|
-
contents: `import * as React from "${module}";${content}`,
|
|
176
|
-
loader: "jsx",
|
|
177
|
-
};
|
|
178
|
-
})
|
|
179
|
-
);
|
|
180
|
-
},
|
|
181
|
-
},
|
|
182
|
-
],
|
|
183
|
-
});
|
|
184
|
-
};
|
|
185
|
-
});
|
|
186
|
-
exports.createBundler = createBundler;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare type Project = ReturnType<typeof createProject>;
|
|
2
|
-
export declare const createProject: () => {
|
|
3
|
-
readonly source: string;
|
|
4
|
-
readonly destination: {
|
|
5
|
-
readonly cjs: string;
|
|
6
|
-
readonly esm: string;
|
|
7
|
-
};
|
|
8
|
-
readonly externalDependencies: string[];
|
|
9
|
-
readonly hasModule: (name: string) => boolean;
|
|
10
|
-
};
|
package/bin/entities/project.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createProject = void 0;
|
|
4
|
-
const path_1 = require("path");
|
|
5
|
-
const constants_1 = require("../constants");
|
|
6
|
-
const createProject = () => {
|
|
7
|
-
const {
|
|
8
|
-
dependencies = {},
|
|
9
|
-
devDependencies = {},
|
|
10
|
-
peerDependencies = {},
|
|
11
|
-
main,
|
|
12
|
-
module,
|
|
13
|
-
source,
|
|
14
|
-
} = require(path_1.resolve(constants_1.CWD, "package.json"));
|
|
15
|
-
const externalDependencies = Object.keys(peerDependencies);
|
|
16
|
-
const allDependencies = [
|
|
17
|
-
...externalDependencies,
|
|
18
|
-
...Object.keys(dependencies),
|
|
19
|
-
...Object.keys(devDependencies),
|
|
20
|
-
];
|
|
21
|
-
return {
|
|
22
|
-
source,
|
|
23
|
-
destination: {
|
|
24
|
-
cjs: main,
|
|
25
|
-
esm: module,
|
|
26
|
-
},
|
|
27
|
-
externalDependencies,
|
|
28
|
-
hasModule(name) {
|
|
29
|
-
return allDependencies.includes(name);
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
exports.createProject = createProject;
|