quickbundle 0.3.0 → 0.6.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/README.md +60 -3
- package/bin/bundler/bundler.d.ts +9 -0
- package/bin/bundler/bundler.js +74 -0
- package/bin/bundler/index.d.ts +3 -0
- package/bin/bundler/index.js +7 -0
- package/bin/bundler/metadata.d.ts +12 -0
- package/bin/bundler/metadata.js +27 -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 +1 -3
- package/bin/helpers.js +14 -15
- package/bin/index.d.ts +1 -1
- package/bin/index.js +1 -13
- 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 -1133
- package/bin/types.d.ts +1 -0
- package/bin/types.js +2 -0
- package/package.json +17 -15
- package/bin/commands/build.js +0 -95
- package/bin/commands/watch.d.ts +0 -1
- package/bin/commands/watch.js +0 -68
- package/bin/entities/bundler.d.ts +0 -12
- package/bin/entities/bundler.js +0 -118
- package/bin/entities/project.d.ts +0 -10
- package/bin/entities/project.js +0 -33
- package/bin/entities/typescript.d.ts +0 -6
- package/bin/entities/typescript.js +0 -118
package/bin/types.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare type ModuleFormat = "esm" | "cjs";
|
package/bin/types.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quickbundle",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"bin": {
|
|
5
5
|
"quickbundle": "bin/index.js"
|
|
6
6
|
},
|
|
@@ -20,32 +20,34 @@
|
|
|
20
20
|
"main": "bin/index.js",
|
|
21
21
|
"scripts": {
|
|
22
22
|
"prepublishOnly": "yarn lint",
|
|
23
|
-
"prepare": "yarn build",
|
|
24
23
|
"prestart": "yarn build",
|
|
25
24
|
"start": "bin/index.js",
|
|
26
25
|
"clean": "rm -rf bin",
|
|
27
26
|
"build": "tsc && chmod +x bin/index.js",
|
|
28
27
|
"watch": "tsc -w",
|
|
29
|
-
"format": "prettier . --ignore-path .gitignore --
|
|
28
|
+
"format": "prettier . --ignore-path .gitignore --write",
|
|
30
29
|
"lint": "eslint . --ignore-path .gitignore --fix",
|
|
31
30
|
"release": "semantic-release"
|
|
32
31
|
},
|
|
33
32
|
"dependencies": {
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
33
|
+
"esbuild": "0.13.15",
|
|
34
|
+
"gzip-size": "6.0.0",
|
|
35
|
+
"termost": "0.3.0"
|
|
37
36
|
},
|
|
38
37
|
"devDependencies": {
|
|
39
|
-
"@adbayb/eslint-config": "0.
|
|
40
|
-
"@adbayb/prettier-config": "0.
|
|
41
|
-
"@adbayb/ts-config": "0.
|
|
42
|
-
"@commitlint/cli": "
|
|
43
|
-
"@commitlint/config-conventional": "
|
|
44
|
-
"@semantic-release/git": "
|
|
45
|
-
"@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",
|
|
46
46
|
"husky": "4.3.8",
|
|
47
|
-
"lint-staged": "
|
|
48
|
-
"
|
|
47
|
+
"lint-staged": "12.1.2",
|
|
48
|
+
"prettier": "2.4.1",
|
|
49
|
+
"semantic-release": "18.0.0",
|
|
50
|
+
"typescript": "4.5.2"
|
|
49
51
|
},
|
|
50
52
|
"commitlint": {
|
|
51
53
|
"extends": [
|
package/bin/commands/build.js
DELETED
|
@@ -1,95 +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
|
-
var __importDefault =
|
|
38
|
-
(this && this.__importDefault) ||
|
|
39
|
-
function (mod) {
|
|
40
|
-
return mod && mod.__esModule ? mod : { default: mod };
|
|
41
|
-
};
|
|
42
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
-
const terminal_kit_1 = require("@adbayb/terminal-kit");
|
|
44
|
-
const gzip_size_1 = __importDefault(require("gzip-size"));
|
|
45
|
-
const bundler_1 = require("../entities/bundler");
|
|
46
|
-
const project_1 = require("../entities/project");
|
|
47
|
-
const helpers_1 = require("../helpers");
|
|
48
|
-
const calculateBundleSize = (filename) =>
|
|
49
|
-
__awaiter(void 0, void 0, void 0, function* () {
|
|
50
|
-
const content = yield helpers_1.readFile(filename);
|
|
51
|
-
const gzSize = yield gzip_size_1.default(content);
|
|
52
|
-
return {
|
|
53
|
-
raw: content.byteLength,
|
|
54
|
-
gzip: gzSize,
|
|
55
|
-
};
|
|
56
|
-
});
|
|
57
|
-
const formatAllBundleSizes = (filenames) =>
|
|
58
|
-
__awaiter(void 0, void 0, void 0, function* () {
|
|
59
|
-
let output = "";
|
|
60
|
-
for (const filename of filenames) {
|
|
61
|
-
const size = yield calculateBundleSize(filename);
|
|
62
|
-
output += `📦 ${filename}\n${helpers_1.coloredText(
|
|
63
|
-
size.raw.toString().padStart(11) + " B",
|
|
64
|
-
"green"
|
|
65
|
-
)} raw\n${helpers_1.coloredText(
|
|
66
|
-
size.gzip.toString().padStart(11) + " B",
|
|
67
|
-
"green"
|
|
68
|
-
)} gz\n`;
|
|
69
|
-
}
|
|
70
|
-
return output;
|
|
71
|
-
});
|
|
72
|
-
const main = () =>
|
|
73
|
-
__awaiter(void 0, void 0, void 0, function* () {
|
|
74
|
-
const project = project_1.createProject();
|
|
75
|
-
const bundle = yield bundler_1.createBundler(project, {
|
|
76
|
-
isProduction: true,
|
|
77
|
-
isWatchMode: false,
|
|
78
|
-
});
|
|
79
|
-
const formats = ["cjs", "esm"];
|
|
80
|
-
const outfiles = [];
|
|
81
|
-
for (const format of formats) {
|
|
82
|
-
outfiles.push(
|
|
83
|
-
yield terminal_kit_1.run(
|
|
84
|
-
`Building ${format} 👷♂️`,
|
|
85
|
-
bundle(format)
|
|
86
|
-
)
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
const sizeOutput = yield terminal_kit_1.run(
|
|
90
|
-
`Calculating bundle size 📐`,
|
|
91
|
-
formatAllBundleSizes(outfiles)
|
|
92
|
-
);
|
|
93
|
-
console.info(`\n${sizeOutput}`);
|
|
94
|
-
});
|
|
95
|
-
main();
|
package/bin/commands/watch.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/bin/commands/watch.js
DELETED
|
@@ -1,68 +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 helpers_1 = require("../helpers");
|
|
42
|
-
const watchableRun = (promise) => {
|
|
43
|
-
console.clear();
|
|
44
|
-
return terminal_kit_1.run(
|
|
45
|
-
`Watching 🔎 ${helpers_1.coloredText(
|
|
46
|
-
`last at ${new Date().toLocaleTimeString()}`,
|
|
47
|
-
"grey"
|
|
48
|
-
)}`,
|
|
49
|
-
promise
|
|
50
|
-
);
|
|
51
|
-
};
|
|
52
|
-
const main = () =>
|
|
53
|
-
__awaiter(void 0, void 0, void 0, function* () {
|
|
54
|
-
const project = project_1.createProject();
|
|
55
|
-
const bundle = yield bundler_1.createBundler(project, {
|
|
56
|
-
isProduction: false,
|
|
57
|
-
isWatchMode: true,
|
|
58
|
-
onWatch(error) {
|
|
59
|
-
if (error) {
|
|
60
|
-
watchableRun(Promise.reject(error));
|
|
61
|
-
} else {
|
|
62
|
-
watchableRun(Promise.resolve());
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
});
|
|
66
|
-
watchableRun(bundle("esm"));
|
|
67
|
-
});
|
|
68
|
-
main();
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Project } from "./project";
|
|
2
|
-
export declare type BundlerFormat = "esm" | "cjs";
|
|
3
|
-
declare type BundlerOptions = {
|
|
4
|
-
isProduction: boolean;
|
|
5
|
-
isWatchMode: boolean;
|
|
6
|
-
onWatch?: (error: Error | null) => void;
|
|
7
|
-
};
|
|
8
|
-
export declare const createBundler: (
|
|
9
|
-
project: Project,
|
|
10
|
-
{ isProduction, isWatchMode, onWatch }: BundlerOptions
|
|
11
|
-
) => Promise<(format: BundlerFormat) => Promise<string>>;
|
|
12
|
-
export {};
|
package/bin/entities/bundler.js
DELETED
|
@@ -1,118 +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
|
-
exports.createBundler = void 0;
|
|
39
|
-
const esbuild_1 = require("esbuild");
|
|
40
|
-
const constants_1 = require("../constants");
|
|
41
|
-
const helpers_1 = require("../helpers");
|
|
42
|
-
const typescript_1 = require("./typescript");
|
|
43
|
-
const createBundler = (project, { isProduction, isWatchMode, onWatch }) =>
|
|
44
|
-
__awaiter(void 0, void 0, void 0, function* () {
|
|
45
|
-
const tsOptions = yield typescript_1.getTypeScriptOptions();
|
|
46
|
-
return (format) =>
|
|
47
|
-
__awaiter(void 0, void 0, void 0, function* () {
|
|
48
|
-
const outfile = project.destination[format];
|
|
49
|
-
yield esbuild_1.build({
|
|
50
|
-
absWorkingDir: constants_1.CWD,
|
|
51
|
-
bundle: true,
|
|
52
|
-
define: {
|
|
53
|
-
"process.env.NODE_ENV": isProduction
|
|
54
|
-
? '"production"'
|
|
55
|
-
: '"development"',
|
|
56
|
-
},
|
|
57
|
-
entryPoints: [project.source],
|
|
58
|
-
external: project.externalDependencies,
|
|
59
|
-
format,
|
|
60
|
-
metafile: true,
|
|
61
|
-
minify: isProduction,
|
|
62
|
-
outfile,
|
|
63
|
-
sourcemap: true,
|
|
64
|
-
target:
|
|
65
|
-
(tsOptions === null || tsOptions === void 0
|
|
66
|
-
? void 0
|
|
67
|
-
: tsOptions.target) || "esnext",
|
|
68
|
-
watch: isWatchMode && {
|
|
69
|
-
onRebuild: onWatch,
|
|
70
|
-
},
|
|
71
|
-
plugins: [
|
|
72
|
-
{
|
|
73
|
-
name: "jsx",
|
|
74
|
-
setup(build) {
|
|
75
|
-
build.onLoad(
|
|
76
|
-
{ filter: /\.(j|t)sx$/ },
|
|
77
|
-
({ path }) =>
|
|
78
|
-
__awaiter(
|
|
79
|
-
this,
|
|
80
|
-
void 0,
|
|
81
|
-
void 0,
|
|
82
|
-
function* () {
|
|
83
|
-
const module = [
|
|
84
|
-
"preact",
|
|
85
|
-
"react",
|
|
86
|
-
].find(project.hasModule);
|
|
87
|
-
if (
|
|
88
|
-
!module ||
|
|
89
|
-
!helpers_1.resolveModulePath(
|
|
90
|
-
`${module}/jsx-runtime`
|
|
91
|
-
) ||
|
|
92
|
-
(tsOptions === null ||
|
|
93
|
-
tsOptions === void 0
|
|
94
|
-
? void 0
|
|
95
|
-
: tsOptions.hasJsxRuntime) ===
|
|
96
|
-
false
|
|
97
|
-
) {
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
const content = yield helpers_1.readFile(
|
|
101
|
-
path,
|
|
102
|
-
"utf8"
|
|
103
|
-
);
|
|
104
|
-
return {
|
|
105
|
-
contents: `import * as React from "${module}";${content}`,
|
|
106
|
-
loader: "jsx",
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
)
|
|
110
|
-
);
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
],
|
|
114
|
-
});
|
|
115
|
-
return outfile;
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
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;
|
|
@@ -1,118 +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.getTypeScriptOptions = void 0;
|
|
82
|
-
const path_1 = require("path");
|
|
83
|
-
const constants_1 = require("../constants");
|
|
84
|
-
const getTypeScriptOptions = () =>
|
|
85
|
-
__awaiter(void 0, void 0, void 0, function* () {
|
|
86
|
-
var _a;
|
|
87
|
-
try {
|
|
88
|
-
const ts = yield Promise.resolve().then(() =>
|
|
89
|
-
__importStar(require("typescript"))
|
|
90
|
-
);
|
|
91
|
-
const { jsx, target } = ts.parseJsonConfigFileContent(
|
|
92
|
-
require(path_1.resolve(constants_1.CWD, "tsconfig.json")),
|
|
93
|
-
ts.sys,
|
|
94
|
-
constants_1.CWD
|
|
95
|
-
).options;
|
|
96
|
-
const esbuildTarget =
|
|
97
|
-
!target ||
|
|
98
|
-
[ts.ScriptTarget.ESNext, ts.ScriptTarget.Latest].includes(
|
|
99
|
-
target
|
|
100
|
-
)
|
|
101
|
-
? "esnext"
|
|
102
|
-
: (_a = ts.ScriptTarget[target]) === null || _a === void 0
|
|
103
|
-
? void 0
|
|
104
|
-
: _a.toLowerCase();
|
|
105
|
-
return {
|
|
106
|
-
target: esbuildTarget,
|
|
107
|
-
hasJsxRuntime:
|
|
108
|
-
jsx !== undefined &&
|
|
109
|
-
[
|
|
110
|
-
ts.JsxEmit["ReactJSX"],
|
|
111
|
-
ts.JsxEmit["ReactJSXDev"],
|
|
112
|
-
].includes(jsx),
|
|
113
|
-
};
|
|
114
|
-
} catch (error) {
|
|
115
|
-
return null;
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
exports.getTypeScriptOptions = getTypeScriptOptions;
|