quickbundle 0.9.0 → 0.12.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.
@@ -1,7 +1,11 @@
1
1
  declare type BundleParameters = {
2
- isProduction: boolean;
3
- isFast: boolean;
4
- onWatch?: (error: Error | null) => void;
2
+ isProduction: boolean;
3
+ isFast: boolean;
4
+ onWatch?: (error: Error | null) => void;
5
5
  };
6
- export declare const bundle: ({ isProduction, isFast, onWatch, }: BundleParameters) => Promise<(string | null)[]>;
6
+ export declare const bundle: ({
7
+ isProduction,
8
+ isFast,
9
+ onWatch,
10
+ }: BundleParameters) => Promise<(string | null)[]>;
7
11
  export {};
@@ -1,13 +1,39 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
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
+ };
11
37
  Object.defineProperty(exports, "__esModule", { value: true });
12
38
  exports.bundle = void 0;
13
39
  const esbuild_1 = require("esbuild");
@@ -15,71 +41,86 @@ const constants_1 = require("../constants");
15
41
  const package_1 = require("./package");
16
42
  const plugins_1 = require("./plugins");
17
43
  const typescript_1 = require("./typescript");
18
- const bundle = ({ isProduction, isFast, onWatch, }) => __awaiter(void 0, void 0, void 0, function* () {
19
- const { destination, externalDependencies, hasModule, platform, source, types, } = (0, package_1.getPackageMetadata)();
20
- const isWatching = typeof onWatch === "function";
21
- const isTypingRequested = typeof types === "string" && !isFast;
22
- const tsConfig = yield (0, typescript_1.getTypeScriptConfiguration)();
23
- const getType = () => __awaiter(void 0, void 0, void 0, function* () {
24
- const outfile = types;
25
- if (!outfile)
26
- return null;
27
- yield (0, typescript_1.generateTypeScriptDeclaration)(outfile);
28
- return outfile;
29
- });
30
- const getJavaScript = (format) => __awaiter(void 0, void 0, void 0, function* () {
31
- const outfile = destination[format];
32
- if (!outfile)
33
- return null;
34
- yield (0, esbuild_1.build)({
35
- absWorkingDir: constants_1.CWD,
36
- bundle: Boolean(externalDependencies),
37
- define: {
38
- "process.env.NODE_ENV": isProduction
39
- ? '"production"'
40
- : '"development"',
41
- },
42
- entryPoints: [source],
43
- external: externalDependencies,
44
- format,
45
- logLevel: "silent",
46
- metafile: true,
47
- minify: isProduction,
48
- outfile,
49
- plugins: [(0, plugins_1.jsxPlugin)(tsConfig)],
50
- platform,
51
- sourcemap: true,
52
- target: (tsConfig === null || tsConfig === void 0 ? void 0 : tsConfig.target) || "esnext",
53
- treeShaking: true,
54
- watch: isWatching && {
55
- onRebuild(bundleError) {
56
- return __awaiter(this, void 0, void 0, function* () {
57
- let error = bundleError;
58
- if (error) {
59
- onWatch(error);
60
- return;
61
- }
62
- if (isTypingRequested) {
63
- try {
64
- yield getType();
65
- }
66
- catch (typingError) {
67
- error = typingError;
68
- }
69
- }
70
- onWatch(error);
71
- });
72
- },
73
- },
74
- });
75
- return outfile;
76
- });
77
- const promises = [
78
- ...(isWatching
79
- ? [getJavaScript(hasModule ? "esm" : "cjs")]
80
- : [getJavaScript("cjs"), getJavaScript("esm")]),
81
- ...(isTypingRequested ? [getType()] : []),
82
- ];
83
- return Promise.all(promises);
84
- });
44
+ const bundle = ({ isProduction, isFast, onWatch }) =>
45
+ __awaiter(void 0, void 0, void 0, function* () {
46
+ const {
47
+ destination,
48
+ externalDependencies,
49
+ hasModule,
50
+ platform,
51
+ source,
52
+ types,
53
+ } = (0, package_1.getPackageMetadata)();
54
+ const isWatching = typeof onWatch === "function";
55
+ const isTypingRequested = typeof types === "string" && !isFast;
56
+ const tsConfig = yield (0, typescript_1.getTypeScriptConfiguration)();
57
+ const getType = () =>
58
+ __awaiter(void 0, void 0, void 0, function* () {
59
+ const outfile = types;
60
+ if (!outfile) return null;
61
+ yield (0, typescript_1.generateTypeScriptDeclaration)(outfile);
62
+ return outfile;
63
+ });
64
+ const getJavaScript = (format) =>
65
+ __awaiter(void 0, void 0, void 0, function* () {
66
+ const outfile = destination[format];
67
+ if (!outfile) return null;
68
+ yield (0, esbuild_1.build)({
69
+ absWorkingDir: constants_1.CWD,
70
+ bundle: Boolean(externalDependencies),
71
+ define: {
72
+ "process.env.NODE_ENV": isProduction
73
+ ? '"production"'
74
+ : '"development"',
75
+ },
76
+ entryPoints: [source],
77
+ external: externalDependencies,
78
+ format,
79
+ logLevel: "silent",
80
+ metafile: true,
81
+ minify: isProduction,
82
+ outfile,
83
+ plugins: [(0, plugins_1.jsxPlugin)(tsConfig)],
84
+ platform,
85
+ sourcemap: true,
86
+ target:
87
+ (tsConfig === null || tsConfig === void 0
88
+ ? void 0
89
+ : tsConfig.target) || "esnext",
90
+ treeShaking: true,
91
+ watch: isWatching && {
92
+ onRebuild(bundleError) {
93
+ return __awaiter(
94
+ this,
95
+ void 0,
96
+ void 0,
97
+ function* () {
98
+ let error = bundleError;
99
+ if (error) {
100
+ onWatch(error);
101
+ return;
102
+ }
103
+ if (isTypingRequested) {
104
+ try {
105
+ yield getType();
106
+ } catch (typingError) {
107
+ error = typingError;
108
+ }
109
+ }
110
+ onWatch(error);
111
+ }
112
+ );
113
+ },
114
+ },
115
+ });
116
+ return outfile;
117
+ });
118
+ const promises = [
119
+ ...(isWatching
120
+ ? [getJavaScript(hasModule ? "esm" : "cjs")]
121
+ : [getJavaScript("cjs"), getJavaScript("esm")]),
122
+ ...(isTypingRequested ? [getType()] : []),
123
+ ];
124
+ return Promise.all(promises);
125
+ });
85
126
  exports.bundle = bundle;
@@ -2,4 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.bundle = void 0;
4
4
  var bundler_1 = require("./bundler");
5
- Object.defineProperty(exports, "bundle", { enumerable: true, get: function () { return bundler_1.bundle; } });
5
+ Object.defineProperty(exports, "bundle", {
6
+ enumerable: true,
7
+ get: function () {
8
+ return bundler_1.bundle;
9
+ },
10
+ });
@@ -1,11 +1,11 @@
1
1
  export declare const getPackageMetadata: () => {
2
- readonly destination: {
3
- readonly esm?: string | undefined;
4
- readonly cjs: string;
5
- };
6
- readonly externalDependencies: string[];
7
- readonly hasModule: boolean;
8
- readonly platform: "node" | "browser";
9
- readonly source: string;
10
- readonly types: string | undefined;
2
+ readonly destination: {
3
+ readonly esm?: string | undefined;
4
+ readonly cjs: string;
5
+ };
6
+ readonly externalDependencies: string[];
7
+ readonly hasModule: boolean;
8
+ readonly platform: "node" | "browser";
9
+ readonly source: string;
10
+ readonly types: string | undefined;
11
11
  };
@@ -5,18 +5,34 @@ const path_1 = require("path");
5
5
  const constants_1 = require("../constants");
6
6
  const helpers_1 = require("../helpers");
7
7
  const getPackageMetadata = () => {
8
- const { peerDependencies = {}, main, module, platform = "browser", source, types, } = require((0, path_1.resolve)(constants_1.CWD, "package.json"));
9
- const externalDependencies = Object.keys(peerDependencies);
10
- (0, helpers_1.assert)(main, "A `main` field is required in `package.json`. Did you forget to add it?");
11
- (0, helpers_1.assert)(source, "A `source` field is required in `package.json`. Did you forget to add it?");
12
- (0, helpers_1.assert)(["browser", "node"].includes(platform), "The `platform` package field can only accept `browser` or `node` value.");
13
- return {
14
- destination: Object.assign({ cjs: main }, (module && { esm: module })),
15
- externalDependencies,
16
- hasModule: Boolean(module),
17
- platform,
18
- source,
19
- types,
20
- };
8
+ const {
9
+ peerDependencies = {},
10
+ main,
11
+ module,
12
+ platform = "browser",
13
+ source,
14
+ types,
15
+ } = require((0, path_1.resolve)(constants_1.CWD, "package.json"));
16
+ const externalDependencies = Object.keys(peerDependencies);
17
+ (0, helpers_1.assert)(
18
+ main,
19
+ "A `main` field is required in `package.json`. Did you forget to add it?"
20
+ );
21
+ (0, helpers_1.assert)(
22
+ source,
23
+ "A `source` field is required in `package.json`. Did you forget to add it?"
24
+ );
25
+ (0, helpers_1.assert)(
26
+ ["browser", "node"].includes(platform),
27
+ "The `platform` package field can only accept `browser` or `node` value."
28
+ );
29
+ return {
30
+ destination: Object.assign({ cjs: main }, module && { esm: module }),
31
+ externalDependencies,
32
+ hasModule: Boolean(module),
33
+ platform,
34
+ source,
35
+ types,
36
+ };
21
37
  };
22
38
  exports.getPackageMetadata = getPackageMetadata;
@@ -1,3 +1,5 @@
1
1
  import type { Plugin } from "esbuild";
2
2
  import type { TypeScriptConfiguration } from "./typescript";
3
- export declare const jsxPlugin: (tsConfig: TypeScriptConfiguration | null) => Plugin;
3
+ export declare const jsxPlugin: (
4
+ tsConfig: TypeScriptConfiguration | null
5
+ ) => Plugin;
@@ -1,32 +1,63 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
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
+ };
11
37
  Object.defineProperty(exports, "__esModule", { value: true });
12
38
  exports.jsxPlugin = void 0;
13
39
  const helpers_1 = require("../helpers");
14
40
  const jsxPlugin = (tsConfig) => ({
15
- name: "jsx-runtime",
16
- setup(build) {
17
- build.onLoad({ filter: /\.(j|t)sx$/ }, ({ path }) => __awaiter(this, void 0, void 0, function* () {
18
- if (!tsConfig || !tsConfig.hasJsxRuntime)
19
- return;
20
- const module = tsConfig.jsxImportSource || "react";
21
- if (!(0, helpers_1.resolveModulePath)(`${module}/jsx-runtime`)) {
22
- throw new Error("Unable to find the JSX runtime.\nPotential solutions:\n1. If you rely on a non React runtime, set a valid `jsxImportSource` in your tsconfig\n2. Make sure that you've installed your project dependencies");
23
- }
24
- const content = yield (0, helpers_1.readFile)(path, "utf8");
25
- return {
26
- contents: `import * as React from "${module}";${content}`,
27
- loader: "tsx",
28
- };
29
- }));
30
- },
41
+ name: "jsx-runtime",
42
+ setup(build) {
43
+ build.onLoad({ filter: /\.(j|t)sx$/ }, ({ path }) =>
44
+ __awaiter(this, void 0, void 0, function* () {
45
+ if (!tsConfig || !tsConfig.hasJsxRuntime) return;
46
+ const module = tsConfig.jsxImportSource || "react";
47
+ if (
48
+ !(0, helpers_1.resolveModulePath)(`${module}/jsx-runtime`)
49
+ ) {
50
+ throw new Error(
51
+ "Unable to find the JSX runtime.\nPotential solutions:\n1. If you rely on a non React runtime, set a valid `jsxImportSource` in your tsconfig\n2. Make sure that you've installed your project dependencies"
52
+ );
53
+ }
54
+ const content = yield (0, helpers_1.readFile)(path, "utf8");
55
+ return {
56
+ contents: `import * as React from "${module}";${content}`,
57
+ loader: "tsx",
58
+ };
59
+ })
60
+ );
61
+ },
31
62
  });
32
63
  exports.jsxPlugin = jsxPlugin;
@@ -1,8 +1,12 @@
1
1
  export declare type TypeScriptConfiguration = {
2
- target?: string;
3
- jsxImportSource?: string;
4
- hasJsxRuntime?: boolean;
2
+ target?: string;
3
+ jsxImportSource?: string;
4
+ hasJsxRuntime?: boolean;
5
5
  };
6
6
  export declare const getTypeScriptConfiguration: () => Promise<TypeScriptConfiguration | null>;
7
- export declare const generateTypeScriptDeclaration: (outfile: string) => Promise<string>;
8
- export declare const hasTypeScript: (tsConfig: TypeScriptConfiguration | null) => tsConfig is TypeScriptConfiguration;
7
+ export declare const generateTypeScriptDeclaration: (
8
+ outfile: string
9
+ ) => Promise<string>;
10
+ export declare const hasTypeScript: (
11
+ tsConfig: TypeScriptConfiguration | null
12
+ ) => tsConfig is TypeScriptConfiguration;
@@ -1,75 +1,154 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
2
+ var __createBinding =
3
+ (this && this.__createBinding) ||
4
+ (Object.create
5
+ ? function (o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (
9
+ !desc ||
10
+ ("get" in desc
11
+ ? !m.__esModule
12
+ : desc.writable || desc.configurable)
13
+ ) {
14
+ desc = {
15
+ enumerable: true,
16
+ get: function () {
17
+ return m[k];
18
+ },
19
+ };
20
+ }
21
+ Object.defineProperty(o, k2, desc);
22
+ }
23
+ : function (o, m, k, k2) {
24
+ if (k2 === undefined) k2 = k;
25
+ o[k2] = m[k];
26
+ });
27
+ var __setModuleDefault =
28
+ (this && this.__setModuleDefault) ||
29
+ (Object.create
30
+ ? function (o, v) {
31
+ Object.defineProperty(o, "default", {
32
+ enumerable: true,
33
+ value: v,
34
+ });
35
+ }
36
+ : function (o, v) {
37
+ o["default"] = v;
38
+ });
39
+ var __importStar =
40
+ (this && this.__importStar) ||
41
+ function (mod) {
42
+ if (mod && mod.__esModule) return mod;
43
+ var result = {};
44
+ if (mod != null)
45
+ for (var k in mod)
46
+ if (
47
+ k !== "default" &&
48
+ Object.prototype.hasOwnProperty.call(mod, k)
49
+ )
50
+ __createBinding(result, mod, k);
51
+ __setModuleDefault(result, mod);
52
+ return result;
53
+ };
54
+ var __awaiter =
55
+ (this && this.__awaiter) ||
56
+ function (thisArg, _arguments, P, generator) {
57
+ function adopt(value) {
58
+ return value instanceof P
59
+ ? value
60
+ : new P(function (resolve) {
61
+ resolve(value);
62
+ });
63
+ }
64
+ return new (P || (P = Promise))(function (resolve, reject) {
65
+ function fulfilled(value) {
66
+ try {
67
+ step(generator.next(value));
68
+ } catch (e) {
69
+ reject(e);
70
+ }
71
+ }
72
+ function rejected(value) {
73
+ try {
74
+ step(generator["throw"](value));
75
+ } catch (e) {
76
+ reject(e);
77
+ }
78
+ }
79
+ function step(result) {
80
+ result.done
81
+ ? resolve(result.value)
82
+ : adopt(result.value).then(fulfilled, rejected);
83
+ }
84
+ step(
85
+ (generator = generator.apply(thisArg, _arguments || [])).next()
86
+ );
87
+ });
88
+ };
34
89
  Object.defineProperty(exports, "__esModule", { value: true });
35
- exports.hasTypeScript = exports.generateTypeScriptDeclaration = exports.getTypeScriptConfiguration = void 0;
90
+ exports.hasTypeScript =
91
+ exports.generateTypeScriptDeclaration =
92
+ exports.getTypeScriptConfiguration =
93
+ void 0;
36
94
  const path_1 = require("path");
37
95
  const termost_1 = require("termost");
38
96
  const constants_1 = require("../constants");
39
- const getTypeScriptConfiguration = () => __awaiter(void 0, void 0, void 0, function* () {
40
- var _a;
41
- try {
42
- const ts = yield Promise.resolve().then(() => __importStar(require("typescript")));
43
- const { jsx, jsxImportSource, target } = ts.parseJsonConfigFileContent(require((0, path_1.resolve)(constants_1.CWD, "tsconfig.json")), ts.sys, constants_1.CWD).options;
44
- const esbuildTarget = !target ||
45
- [ts.ScriptTarget.ESNext, ts.ScriptTarget.Latest].includes(target)
46
- ? "esnext"
47
- : (_a = ts.ScriptTarget[target]) === null || _a === void 0 ? void 0 : _a.toLowerCase();
48
- const hasJsxRuntime = jsx !== undefined &&
49
- [ts.JsxEmit["ReactJSX"], ts.JsxEmit["ReactJSXDev"]].includes(jsx);
50
- return {
51
- target: esbuildTarget,
52
- jsxImportSource,
53
- hasJsxRuntime,
54
- };
55
- }
56
- catch (error) {
57
- return null;
58
- }
59
- });
97
+ const getTypeScriptConfiguration = () =>
98
+ __awaiter(void 0, void 0, void 0, function* () {
99
+ var _a;
100
+ try {
101
+ const ts = yield Promise.resolve().then(() =>
102
+ __importStar(require("typescript"))
103
+ );
104
+ const { jsx, jsxImportSource, target } =
105
+ ts.parseJsonConfigFileContent(
106
+ require((0, path_1.resolve)(
107
+ constants_1.CWD,
108
+ "tsconfig.json"
109
+ )),
110
+ ts.sys,
111
+ constants_1.CWD
112
+ ).options;
113
+ const esbuildTarget =
114
+ !target ||
115
+ [ts.ScriptTarget.ESNext, ts.ScriptTarget.Latest].includes(
116
+ target
117
+ )
118
+ ? "esnext"
119
+ : (_a = ts.ScriptTarget[target]) === null || _a === void 0
120
+ ? void 0
121
+ : _a.toLowerCase();
122
+ const hasJsxRuntime =
123
+ jsx !== undefined &&
124
+ [ts.JsxEmit["ReactJSX"], ts.JsxEmit["ReactJSXDev"]].includes(
125
+ jsx
126
+ );
127
+ return {
128
+ target: esbuildTarget,
129
+ jsxImportSource,
130
+ hasJsxRuntime,
131
+ };
132
+ } catch (error) {
133
+ return null;
134
+ }
135
+ });
60
136
  exports.getTypeScriptConfiguration = getTypeScriptConfiguration;
61
- const generateTypeScriptDeclaration = (outfile) => __awaiter(void 0, void 0, void 0, function* () {
62
- const outdir = (0, path_1.dirname)(outfile);
63
- try {
64
- yield termost_1.helpers.exec(`tsc --declaration --emitDeclarationOnly --incremental --removeComments false --outDir ${outdir}`, { cwd: constants_1.CWD });
65
- return outdir;
66
- }
67
- catch (error) {
68
- throw new Error(`Type generation failed:\n${error}`);
69
- }
70
- });
137
+ const generateTypeScriptDeclaration = (outfile) =>
138
+ __awaiter(void 0, void 0, void 0, function* () {
139
+ const outdir = (0, path_1.dirname)(outfile);
140
+ try {
141
+ yield termost_1.helpers.exec(
142
+ `tsc --declaration --emitDeclarationOnly --incremental --removeComments false --outDir ${outdir}`,
143
+ { cwd: constants_1.CWD }
144
+ );
145
+ return outdir;
146
+ } catch (error) {
147
+ throw new Error(`Type generation failed:\n${error}`);
148
+ }
149
+ });
71
150
  exports.generateTypeScriptDeclaration = generateTypeScriptDeclaration;
72
151
  const hasTypeScript = (tsConfig) => {
73
- return Boolean(tsConfig);
152
+ return Boolean(tsConfig);
74
153
  };
75
154
  exports.hasTypeScript = hasTypeScript;
package/bin/helpers.d.ts CHANGED
@@ -2,4 +2,7 @@
2
2
  import { readFile as fsReadFile } from "fs";
3
3
  export declare const readFile: typeof fsReadFile.__promisify__;
4
4
  export declare const resolveModulePath: (path: string) => boolean;
5
- export declare function assert(condition: unknown, message: string): asserts condition;
5
+ export declare function assert(
6
+ condition: unknown,
7
+ message: string
8
+ ): asserts condition;