quickbundle 0.2.0 → 0.4.0

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/bin/types.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare type ModuleFormat = "esm" | "cjs";
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- console.info("TODO");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quickbundle",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "bin": {
5
5
  "quickbundle": "bin/index.js"
6
6
  },
@@ -17,37 +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
- "prepare": "yarn build",
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 --ignore-path .prettierignore --write",
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
- "@adbayb/terminal-kit": "0.6.0",
33
- "esbuild": "0.11.7"
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.6.0",
37
- "@adbayb/prettier-config": "0.6.0",
38
- "@adbayb/ts-config": "0.6.0",
39
- "@commitlint/cli": "12.1.1",
40
- "@commitlint/config-conventional": "12.1.1",
41
- "@types/node": "14.14.37",
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",
42
46
  "husky": "4.3.8",
43
- "lint-staged": "10.5.4",
44
- "semantic-release": "17.4.2"
45
- },
46
- "release": {
47
- "branches": [
48
- "main"
49
- ],
50
- "ci": false
47
+ "lint-staged": "12.1.2",
48
+ "prettier": "2.4.1",
49
+ "semantic-release": "18.0.0",
50
+ "typescript": "4.5.2"
51
51
  },
52
52
  "commitlint": {
53
53
  "extends": [
@@ -71,5 +71,58 @@
71
71
  "**/*.{json,md,mdx,html,css}": [
72
72
  "yarn format"
73
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
+ ]
74
127
  }
75
128
  }
@@ -1,225 +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
- const path_1 = require("path");
82
- const esbuild_1 = require("esbuild");
83
- const terminal_kit_1 = require("@adbayb/terminal-kit");
84
- const constants_1 = require("../constants");
85
- const createProject = () => {
86
- const {
87
- dependencies = {},
88
- devDependencies = {},
89
- peerDependencies = {},
90
- main,
91
- module,
92
- source,
93
- } = require(path_1.resolve(constants_1.CWD, "package.json"));
94
- const externalDependencies = Object.keys(peerDependencies);
95
- const allDependencies = [
96
- ...externalDependencies,
97
- ...Object.keys(dependencies),
98
- ...Object.keys(devDependencies),
99
- ];
100
- return {
101
- source,
102
- destination: {
103
- cjs: main,
104
- esm: module,
105
- },
106
- externalDependencies,
107
- hasModule(name) {
108
- return allDependencies.includes(name);
109
- },
110
- };
111
- };
112
- const resolveModulePath = (path) => {
113
- try {
114
- return Boolean(require.resolve(path));
115
- } catch (error) {
116
- return false;
117
- }
118
- };
119
- const getTypeScriptOptions = () =>
120
- __awaiter(void 0, void 0, void 0, function* () {
121
- var _a;
122
- try {
123
- const ts = yield Promise.resolve().then(() =>
124
- __importStar(require("typescript"))
125
- );
126
- const { jsx, target } = ts.parseJsonConfigFileContent(
127
- require(path_1.resolve(constants_1.CWD, "tsconfig.json")),
128
- ts.sys,
129
- constants_1.CWD
130
- ).options;
131
- const esbuildTarget =
132
- !target ||
133
- [ts.ScriptTarget.ESNext, ts.ScriptTarget.Latest].includes(
134
- target
135
- )
136
- ? "esnext"
137
- : (_a = ts.ScriptTarget[target]) === null || _a === void 0
138
- ? void 0
139
- : _a.toLowerCase();
140
- return {
141
- target: esbuildTarget,
142
- hasJsxRuntime:
143
- jsx !== undefined &&
144
- [
145
- ts.JsxEmit["ReactJSX"],
146
- ts.JsxEmit["ReactJSXDev"],
147
- ].includes(jsx),
148
- };
149
- } catch (error) {
150
- return null;
151
- }
152
- });
153
- const createBundler = (project) =>
154
- __awaiter(void 0, void 0, void 0, function* () {
155
- const tsOptions = yield getTypeScriptOptions();
156
- return (format, isProduction) => {
157
- return esbuild_1.build({
158
- absWorkingDir: constants_1.CWD,
159
- bundle: true,
160
- define: {
161
- "process.env.NODE_ENV": isProduction
162
- ? '"production"'
163
- : '"development"',
164
- },
165
- entryPoints: [project.source],
166
- external: project.externalDependencies,
167
- format,
168
- minify: isProduction,
169
- outfile: project.destination[format],
170
- sourcemap: !isProduction,
171
- target:
172
- (tsOptions === null || tsOptions === void 0
173
- ? void 0
174
- : tsOptions.target) || "esnext",
175
- plugins: [
176
- {
177
- name: "jsx-runtime",
178
- setup(build) {
179
- const fs = require("fs");
180
- build.onLoad({ filter: /\.(j|t)sx$/ }, ({ path }) =>
181
- __awaiter(this, void 0, void 0, function* () {
182
- const module = ["preact", "react"].find(
183
- project.hasModule
184
- );
185
- if (
186
- !module ||
187
- !resolveModulePath(
188
- `${module}/jsx-runtime`
189
- ) ||
190
- (tsOptions === null ||
191
- tsOptions === void 0
192
- ? void 0
193
- : tsOptions.hasJsxRuntime) === false
194
- ) {
195
- return;
196
- }
197
- const content = yield fs.promises.readFile(
198
- path,
199
- "utf8"
200
- );
201
- return {
202
- contents: `import * as React from "${module}";${content}`,
203
- loader: "jsx",
204
- };
205
- })
206
- );
207
- },
208
- },
209
- ],
210
- });
211
- };
212
- });
213
- const main = () =>
214
- __awaiter(void 0, void 0, void 0, function* () {
215
- const project = createProject();
216
- const bundle = yield createBundler(project);
217
- const formats = ["cjs", "esm"];
218
- for (const format of formats) {
219
- yield terminal_kit_1.run(
220
- `Building ${format} 👷‍♂️`,
221
- bundle(format, false)
222
- );
223
- }
224
- });
225
- main();
@@ -1 +0,0 @@
1
- export {};