bunchee 6.8.1 → 6.8.2
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 +0 -22
- package/dist/bin/cli.js +56 -23
- package/dist/index.d.ts +0 -1
- package/dist/index.js +25 -91
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -317,19 +317,6 @@ bunchee --no-external
|
|
|
317
317
|
|
|
318
318
|
This will include all dependencies within your output bundle.
|
|
319
319
|
|
|
320
|
-
#### TypeScript-Go Compiler
|
|
321
|
-
|
|
322
|
-
TypeScript-Go (`@typescript/native-preview`) is a high-performance, Go-based implementation of the TypeScript compiler that can significantly speed up type declaration file generation.
|
|
323
|
-
|
|
324
|
-
To use TypeScript-Go for type generation, use the `--tsgo` flag:
|
|
325
|
-
|
|
326
|
-
**Note**: This requires `@typescript/native-preview` to be installed as a dev dependency. If it's not installed, bunchee will exit with an error.
|
|
327
|
-
|
|
328
|
-
```sh
|
|
329
|
-
pnpm add -D bunchee @typescript/native-preview
|
|
330
|
-
bunchee --tsgo
|
|
331
|
-
```
|
|
332
|
-
|
|
333
320
|
#### Build Successful Command
|
|
334
321
|
|
|
335
322
|
A command to be executed after a build is successful can be specified using the `--success` option, which is useful for development watching mode:
|
|
@@ -378,14 +365,6 @@ Then use use the [exports field in package.json](https://nodejs.org/api/packages
|
|
|
378
365
|
|
|
379
366
|
If you're building a TypeScript library, separate the types from the main entry file and specify the types path in package.json. Types exports need to stay on the top of each export with `types` condition, and you can use `default` condition for the JS bundle file.
|
|
380
367
|
|
|
381
|
-
**bunchee** supports using the TypeScript-Go compiler (`@typescript/native-preview`) for faster type generation. To enable it, use the `--tsgo` flag:
|
|
382
|
-
|
|
383
|
-
```sh
|
|
384
|
-
bunchee --tsgo
|
|
385
|
-
```
|
|
386
|
-
|
|
387
|
-
Note: This requires `@typescript/native-preview` to be installed as a dev dependency. If it's not installed, bunchee will fall back to the regular TypeScript compiler with a warning.
|
|
388
|
-
|
|
389
368
|
```json5
|
|
390
369
|
{
|
|
391
370
|
"files": ["dist"],
|
|
@@ -566,7 +545,6 @@ await bundle(path.resolve('./src/index.ts'), {
|
|
|
566
545
|
cwd: process.cwd(), // string
|
|
567
546
|
clean: true, // boolean
|
|
568
547
|
tsconfig: 'tsconfig.json', // string
|
|
569
|
-
tsgo: false, // Boolean - use TypeScript-Go compiler for type generation
|
|
570
548
|
})
|
|
571
549
|
```
|
|
572
550
|
|
package/dist/bin/cli.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
var path = require('path');
|
|
3
|
-
var module$1 = require('module');
|
|
4
3
|
var yargs = require('yargs');
|
|
5
4
|
var helpers = require('yargs/helpers');
|
|
6
5
|
var perf_hooks = require('perf_hooks');
|
|
@@ -9,6 +8,7 @@ var fsp = require('fs/promises');
|
|
|
9
8
|
var require$$0 = require('tty');
|
|
10
9
|
var picomatch = require('picomatch');
|
|
11
10
|
var index_js = require('../index.js');
|
|
11
|
+
require('module');
|
|
12
12
|
var tinyglobby = require('tinyglobby');
|
|
13
13
|
var prettyBytes = require('pretty-bytes');
|
|
14
14
|
var nanospinner = require('nanospinner');
|
|
@@ -146,6 +146,52 @@ const defaultColorFn = (text)=>text;
|
|
|
146
146
|
function color(prefixColor) {
|
|
147
147
|
return pc.isColorSupported ? pc[prefixColor] : defaultColorFn;
|
|
148
148
|
}
|
|
149
|
+
let activeSpinner = null;
|
|
150
|
+
// Store original console methods
|
|
151
|
+
const originalConsole = {
|
|
152
|
+
log: console.log.bind(console),
|
|
153
|
+
warn: console.warn.bind(console),
|
|
154
|
+
error: console.error.bind(console),
|
|
155
|
+
info: console.info.bind(console)
|
|
156
|
+
};
|
|
157
|
+
function isSpinnerActive() {
|
|
158
|
+
if (!activeSpinner) return false;
|
|
159
|
+
const isSpinning = activeSpinner.isSpinning;
|
|
160
|
+
return typeof isSpinning === 'function' ? isSpinning() : isSpinning;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Wrap a console method to pause spinner before logging
|
|
164
|
+
*/ function wrapConsoleMethod(original) {
|
|
165
|
+
return (...args)=>{
|
|
166
|
+
if (isSpinnerActive() && activeSpinner) {
|
|
167
|
+
activeSpinner.clear();
|
|
168
|
+
original(...args);
|
|
169
|
+
activeSpinner.start();
|
|
170
|
+
} else {
|
|
171
|
+
original(...args);
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Register a spinner so that ALL console output automatically pauses it.
|
|
177
|
+
* This intercepts console.log/warn/error/info globally.
|
|
178
|
+
* Call with `null` to unregister and restore original console methods.
|
|
179
|
+
*/ function setActiveSpinner(spinner) {
|
|
180
|
+
activeSpinner = spinner;
|
|
181
|
+
if (spinner) {
|
|
182
|
+
// Patch global console methods to pause spinner
|
|
183
|
+
console.log = wrapConsoleMethod(originalConsole.log);
|
|
184
|
+
console.warn = wrapConsoleMethod(originalConsole.warn);
|
|
185
|
+
console.error = wrapConsoleMethod(originalConsole.error);
|
|
186
|
+
console.info = wrapConsoleMethod(originalConsole.info);
|
|
187
|
+
} else {
|
|
188
|
+
// Restore original console methods
|
|
189
|
+
console.log = originalConsole.log;
|
|
190
|
+
console.warn = originalConsole.warn;
|
|
191
|
+
console.error = originalConsole.error;
|
|
192
|
+
console.info = originalConsole.info;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
149
195
|
const logger = {
|
|
150
196
|
log (...arg) {
|
|
151
197
|
console.log(...arg);
|
|
@@ -647,12 +693,11 @@ function lint$1(pkg) {
|
|
|
647
693
|
}
|
|
648
694
|
}
|
|
649
695
|
|
|
650
|
-
var version = "6.8.
|
|
696
|
+
var version = "6.8.2";
|
|
651
697
|
|
|
652
|
-
async function writeDefaultTsconfig(tsConfigPath
|
|
698
|
+
async function writeDefaultTsconfig(tsConfigPath) {
|
|
653
699
|
await fs.promises.writeFile(tsConfigPath, JSON.stringify(DEFAULT_TS_CONFIG, null, 2), 'utf-8');
|
|
654
|
-
|
|
655
|
-
logger.log(`Detected using ${compilerName} but tsconfig.json is missing, created a ${pc.blue('tsconfig.json')} for you.`);
|
|
700
|
+
logger.log(`Detected using TypeScript but tsconfig.json is missing, created a ${pc.blue('tsconfig.json')} for you.`);
|
|
656
701
|
}
|
|
657
702
|
|
|
658
703
|
// ./index -> default
|
|
@@ -1151,7 +1196,6 @@ Options:
|
|
|
1151
1196
|
--tsconfig path to tsconfig file, default: tsconfig.json
|
|
1152
1197
|
--dts-bundle bundle type declaration files, default: false
|
|
1153
1198
|
--success <cmd> run command after build success
|
|
1154
|
-
--tsgo use TypeScript-Go compiler for type generation
|
|
1155
1199
|
`;
|
|
1156
1200
|
function help() {
|
|
1157
1201
|
logger.log(helpMessage);
|
|
@@ -1229,9 +1273,6 @@ async function parseCliArgs(argv) {
|
|
|
1229
1273
|
}).option('success', {
|
|
1230
1274
|
type: 'string',
|
|
1231
1275
|
description: 'run command after build success'
|
|
1232
|
-
}).option('tsgo', {
|
|
1233
|
-
type: 'boolean',
|
|
1234
|
-
description: 'use TypeScript-Go compiler for type generation'
|
|
1235
1276
|
}).command('prepare', 'auto configure package.json exports for building', (yargs)=>{
|
|
1236
1277
|
return yargs.option('esm', {
|
|
1237
1278
|
type: 'boolean',
|
|
@@ -1274,8 +1315,7 @@ async function parseCliArgs(argv) {
|
|
|
1274
1315
|
clean: args['clean'] !== false,
|
|
1275
1316
|
env: args['env'],
|
|
1276
1317
|
tsconfig: args['tsconfig'],
|
|
1277
|
-
onSuccess: args['success']
|
|
1278
|
-
tsgo: args['tsgo']
|
|
1318
|
+
onSuccess: args['success']
|
|
1279
1319
|
};
|
|
1280
1320
|
// When minify is enabled, sourcemap should be enabled by default, unless explicitly opted out
|
|
1281
1321
|
if (parsedArgs.minify && typeof args['sourcemap'] === 'undefined') {
|
|
@@ -1304,20 +1344,9 @@ async function run(args) {
|
|
|
1304
1344
|
env: (env == null ? void 0 : env.split(',')) || [],
|
|
1305
1345
|
clean,
|
|
1306
1346
|
tsconfig,
|
|
1307
|
-
onSuccess
|
|
1308
|
-
tsgo: args.tsgo
|
|
1347
|
+
onSuccess
|
|
1309
1348
|
};
|
|
1310
1349
|
const cliEntry = source ? path__default.default.resolve(cwd, source) : '';
|
|
1311
|
-
// Check if ts-go is available when requested (before any build operations)
|
|
1312
|
-
if (args.tsgo) {
|
|
1313
|
-
try {
|
|
1314
|
-
require.resolve('@typescript/native-preview', {
|
|
1315
|
-
paths: module$1.Module._nodeModulePaths(cwd)
|
|
1316
|
-
});
|
|
1317
|
-
} catch {
|
|
1318
|
-
exit('--tsgo flag was specified but @typescript/native-preview is not installed. Please install it as a dev dependency: pnpm add -D @typescript/native-preview');
|
|
1319
|
-
}
|
|
1320
|
-
}
|
|
1321
1350
|
// lint package by default
|
|
1322
1351
|
await lint(cwd);
|
|
1323
1352
|
const spinnerInstance = process.stdout.isTTY ? nanospinner.createSpinner('Building...\n\n', {
|
|
@@ -1329,6 +1358,8 @@ async function run(args) {
|
|
|
1329
1358
|
success: ()=>{},
|
|
1330
1359
|
isSpinning: false
|
|
1331
1360
|
};
|
|
1361
|
+
// Register spinner with logger so logs automatically pause the spinner
|
|
1362
|
+
setActiveSpinner(spinnerInstance);
|
|
1332
1363
|
const spinner = {
|
|
1333
1364
|
start: startSpinner,
|
|
1334
1365
|
stop: stopSpinner
|
|
@@ -1408,6 +1439,8 @@ async function run(args) {
|
|
|
1408
1439
|
} else {
|
|
1409
1440
|
spinner.stop(`bunchee ${version} build completed`);
|
|
1410
1441
|
}
|
|
1442
|
+
// Unregister spinner from logger
|
|
1443
|
+
setActiveSpinner(null);
|
|
1411
1444
|
}
|
|
1412
1445
|
async function main() {
|
|
1413
1446
|
let params, error;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -4,8 +4,8 @@ var fsp = require('fs/promises');
|
|
|
4
4
|
var fs = require('fs');
|
|
5
5
|
var path = require('path');
|
|
6
6
|
require('pretty-bytes');
|
|
7
|
-
var tinyglobby = require('tinyglobby');
|
|
8
7
|
var require$$0 = require('tty');
|
|
8
|
+
var tinyglobby = require('tinyglobby');
|
|
9
9
|
var module$1 = require('module');
|
|
10
10
|
var rollup = require('rollup');
|
|
11
11
|
var pluginWasm = require('@rollup/plugin-wasm');
|
|
@@ -97,6 +97,13 @@ const defaultColorFn = (text)=>text;
|
|
|
97
97
|
function color(prefixColor) {
|
|
98
98
|
return pc.isColorSupported ? pc[prefixColor] : defaultColorFn;
|
|
99
99
|
}
|
|
100
|
+
// Store original console methods
|
|
101
|
+
({
|
|
102
|
+
log: console.log.bind(console),
|
|
103
|
+
warn: console.warn.bind(console),
|
|
104
|
+
error: console.error.bind(console),
|
|
105
|
+
info: console.info.bind(console)
|
|
106
|
+
});
|
|
100
107
|
const logger = {
|
|
101
108
|
log (...arg) {
|
|
102
109
|
console.log(...arg);
|
|
@@ -299,7 +306,7 @@ function validateEntryFiles(entryFiles) {
|
|
|
299
306
|
|
|
300
307
|
function exit(err) {
|
|
301
308
|
logger.error(err);
|
|
302
|
-
throw
|
|
309
|
+
throw new Error(err) ;
|
|
303
310
|
}
|
|
304
311
|
async function getPackageMeta(cwd) {
|
|
305
312
|
const pkgFilePath = path__default.default.resolve(cwd, 'package.json');
|
|
@@ -1034,40 +1041,7 @@ const memoizeByKey = (fn)=>{
|
|
|
1034
1041
|
const memoize = (fn)=>createMemoize(fn);
|
|
1035
1042
|
|
|
1036
1043
|
let hasLoggedTsWarning = false;
|
|
1037
|
-
|
|
1038
|
-
function resolveTsGo(cwd) {
|
|
1039
|
-
let tsgo;
|
|
1040
|
-
const m = new module$1.Module('', undefined);
|
|
1041
|
-
m.paths = module$1.Module._nodeModulePaths(cwd);
|
|
1042
|
-
try {
|
|
1043
|
-
// Bun does not yet support the `Module` class properly.
|
|
1044
|
-
if (typeof (m == null ? void 0 : m.require) === 'undefined') {
|
|
1045
|
-
const tsgoPath = require.resolve('@typescript/native-preview', {
|
|
1046
|
-
paths: module$1.Module._nodeModulePaths(cwd)
|
|
1047
|
-
});
|
|
1048
|
-
tsgo = require(tsgoPath);
|
|
1049
|
-
} else {
|
|
1050
|
-
tsgo = m.require('@typescript/native-preview');
|
|
1051
|
-
}
|
|
1052
|
-
// ts-go exports the TypeScript API as default or named export
|
|
1053
|
-
return tsgo.default || tsgo;
|
|
1054
|
-
} catch (e) {
|
|
1055
|
-
if (!hasLoggedTsGoWarning) {
|
|
1056
|
-
hasLoggedTsGoWarning = true;
|
|
1057
|
-
logger.warn('Could not load TypeScript-Go compiler. Make sure `@typescript/native-preview` is installed as a dev dependency.');
|
|
1058
|
-
}
|
|
1059
|
-
return null;
|
|
1060
|
-
}
|
|
1061
|
-
}
|
|
1062
|
-
function resolveTypescript(cwd, useTsGo) {
|
|
1063
|
-
if (useTsGo) {
|
|
1064
|
-
const tsgo = resolveTsGo(cwd);
|
|
1065
|
-
if (tsgo) {
|
|
1066
|
-
return tsgo;
|
|
1067
|
-
}
|
|
1068
|
-
// Error if ts-go is requested but not available
|
|
1069
|
-
exit('TypeScript-Go compiler not found. Please install @typescript/native-preview as a dev dependency: pnpm add -D @typescript/native-preview');
|
|
1070
|
-
}
|
|
1044
|
+
function resolveTypescript(cwd) {
|
|
1071
1045
|
let ts;
|
|
1072
1046
|
const m = new module$1.Module('', undefined);
|
|
1073
1047
|
m.paths = module$1.Module._nodeModulePaths(cwd);
|
|
@@ -1095,11 +1069,11 @@ const resolveTsConfigPath = memoize((cwd, tsconfigFileName = 'tsconfig.json')=>{
|
|
|
1095
1069
|
tsConfigPath = path.resolve(cwd, tsconfigFileName);
|
|
1096
1070
|
return fileExists(tsConfigPath) ? tsConfigPath : undefined;
|
|
1097
1071
|
});
|
|
1098
|
-
function resolveTsConfigHandler(cwd, tsConfigPath
|
|
1072
|
+
function resolveTsConfigHandler(cwd, tsConfigPath) {
|
|
1099
1073
|
let tsCompilerOptions = {};
|
|
1100
1074
|
if (tsConfigPath) {
|
|
1101
1075
|
// Use the original ts handler to avoid memory leak
|
|
1102
|
-
const ts = resolveTypescript(cwd
|
|
1076
|
+
const ts = resolveTypescript(cwd);
|
|
1103
1077
|
const basePath = tsConfigPath ? path.dirname(tsConfigPath) : cwd;
|
|
1104
1078
|
const tsconfigJSON = ts.readConfigFile(tsConfigPath, ts.sys.readFile).config;
|
|
1105
1079
|
tsCompilerOptions = ts.parseJsonConfigFileContent(tsconfigJSON, ts.sys, basePath).options;
|
|
@@ -1111,28 +1085,24 @@ function resolveTsConfigHandler(cwd, tsConfigPath, useTsGo) {
|
|
|
1111
1085
|
tsConfigPath
|
|
1112
1086
|
};
|
|
1113
1087
|
}
|
|
1114
|
-
// Note: We can't memoize resolveTsConfigHandler directly with useTsGo parameter
|
|
1115
|
-
// because memoize doesn't handle optional parameters well. Instead, we'll create
|
|
1116
|
-
// a wrapper that handles the memoization per useTsGo value.
|
|
1117
1088
|
const resolveTsConfigCache = new Map();
|
|
1118
|
-
function resolveTsConfig(cwd, tsConfigPath
|
|
1119
|
-
const cacheKey = `${cwd}:${tsConfigPath || ''}
|
|
1089
|
+
function resolveTsConfig(cwd, tsConfigPath) {
|
|
1090
|
+
const cacheKey = `${cwd}:${tsConfigPath || ''}`;
|
|
1120
1091
|
if (resolveTsConfigCache.has(cacheKey)) {
|
|
1121
1092
|
return resolveTsConfigCache.get(cacheKey);
|
|
1122
1093
|
}
|
|
1123
|
-
const result = resolveTsConfigHandler(cwd, tsConfigPath
|
|
1094
|
+
const result = resolveTsConfigHandler(cwd, tsConfigPath);
|
|
1124
1095
|
resolveTsConfigCache.set(cacheKey, result);
|
|
1125
1096
|
return result;
|
|
1126
1097
|
}
|
|
1127
|
-
async function convertCompilerOptions(cwd, json
|
|
1098
|
+
async function convertCompilerOptions(cwd, json) {
|
|
1128
1099
|
// Use the original ts handler to avoid memory leak
|
|
1129
|
-
const ts = resolveTypescript(cwd
|
|
1100
|
+
const ts = resolveTypescript(cwd);
|
|
1130
1101
|
return ts.convertCompilerOptionsFromJson(json, './');
|
|
1131
1102
|
}
|
|
1132
|
-
async function writeDefaultTsconfig(tsConfigPath
|
|
1103
|
+
async function writeDefaultTsconfig(tsConfigPath) {
|
|
1133
1104
|
await fs.promises.writeFile(tsConfigPath, JSON.stringify(DEFAULT_TS_CONFIG, null, 2), 'utf-8');
|
|
1134
|
-
|
|
1135
|
-
logger.log(`Detected using ${compilerName} but tsconfig.json is missing, created a ${pc.blue('tsconfig.json')} for you.`);
|
|
1105
|
+
logger.log(`Detected using TypeScript but tsconfig.json is missing, created a ${pc.blue('tsconfig.json')} for you.`);
|
|
1136
1106
|
}
|
|
1137
1107
|
|
|
1138
1108
|
/**
|
|
@@ -1640,7 +1610,7 @@ const swcMinifyOptions = {
|
|
|
1640
1610
|
toplevel: true
|
|
1641
1611
|
}
|
|
1642
1612
|
};
|
|
1643
|
-
async function createDtsPlugin(tsCompilerOptions, tsConfigPath, respectExternal, cwd
|
|
1613
|
+
async function createDtsPlugin(tsCompilerOptions, tsConfigPath, respectExternal, cwd) {
|
|
1644
1614
|
const enableIncrementalWithoutBuildInfo = (tsCompilerOptions == null ? void 0 : tsCompilerOptions.incremental) && !(tsCompilerOptions == null ? void 0 : tsCompilerOptions.tsBuildInfoFile);
|
|
1645
1615
|
const incrementalOptions = enableIncrementalWithoutBuildInfo ? {
|
|
1646
1616
|
incremental: false
|
|
@@ -1667,31 +1637,7 @@ async function createDtsPlugin(tsCompilerOptions, tsConfigPath, respectExternal,
|
|
|
1667
1637
|
...incrementalOptions,
|
|
1668
1638
|
// error TS6379: Composite projects may not disable incremental compilation.
|
|
1669
1639
|
...compositeOptions
|
|
1670
|
-
}
|
|
1671
|
-
// If useTsGo is enabled, we need to make ts-go available to rollup-plugin-dts
|
|
1672
|
-
// rollup-plugin-dts uses require('typescript') internally, so we need to
|
|
1673
|
-
// temporarily override the module cache to use ts-go
|
|
1674
|
-
if (useTsGo) {
|
|
1675
|
-
const tsgo = resolveTsGo(cwd);
|
|
1676
|
-
if (tsgo) {
|
|
1677
|
-
try {
|
|
1678
|
-
// First, try to resolve typescript to get its path
|
|
1679
|
-
const tsPath = require.resolve('typescript', {
|
|
1680
|
-
paths: module$1.Module._nodeModulePaths(cwd)
|
|
1681
|
-
});
|
|
1682
|
-
// Make ts-go available as 'typescript' for rollup-plugin-dts
|
|
1683
|
-
// This overrides the module cache so rollup-plugin-dts will use ts-go
|
|
1684
|
-
require.cache[tsPath] = {
|
|
1685
|
-
id: tsPath,
|
|
1686
|
-
exports: tsgo,
|
|
1687
|
-
loaded: true
|
|
1688
|
-
};
|
|
1689
|
-
} catch (e) {
|
|
1690
|
-
// If typescript cannot be resolved, we can't override it
|
|
1691
|
-
// rollup-plugin-dts will try to require it and may fail
|
|
1692
|
-
}
|
|
1693
|
-
}
|
|
1694
|
-
}
|
|
1640
|
+
});
|
|
1695
1641
|
const dtsPlugin = require('rollup-plugin-dts').default({
|
|
1696
1642
|
tsconfig: tsConfigPath,
|
|
1697
1643
|
compilerOptions: overrideResolvedTsOptions,
|
|
@@ -1785,8 +1731,8 @@ async function buildInputConfig(entry, bundleConfig, exportCondition, buildConte
|
|
|
1785
1731
|
// Each process should be unique
|
|
1786
1732
|
// Each package build should be unique
|
|
1787
1733
|
// Composing above factors into a unique cache key to retrieve the memoized dts plugin with tsconfigs
|
|
1788
|
-
const uniqueProcessId = 'dts-plugin:' + process.pid + tsConfigPath
|
|
1789
|
-
const dtsPlugin = await memoizeDtsPluginByKey(uniqueProcessId)(tsCompilerOptions, tsConfigPath, bundleConfig.dts && bundleConfig.dts.respectExternal, cwd
|
|
1734
|
+
const uniqueProcessId = 'dts-plugin:' + process.pid + tsConfigPath;
|
|
1735
|
+
const dtsPlugin = await memoizeDtsPluginByKey(uniqueProcessId)(tsCompilerOptions, tsConfigPath, bundleConfig.dts && bundleConfig.dts.respectExternal, cwd);
|
|
1790
1736
|
typesPlugins.push(dtsPlugin);
|
|
1791
1737
|
}
|
|
1792
1738
|
const plugins = (dts ? typesPlugins : [
|
|
@@ -2263,17 +2209,8 @@ async function bundle(cliEntryPath, { cwd: _cwd, onSuccess, ...options } = {}) {
|
|
|
2263
2209
|
// Original input file path, client path might change later
|
|
2264
2210
|
const inputFile = cliEntryPath;
|
|
2265
2211
|
const isFromCli = Boolean(cliEntryPath);
|
|
2266
|
-
const useTsGo = options.tsgo === true;
|
|
2267
|
-
// Check if ts-go is available when requested (before resolving tsconfig)
|
|
2268
|
-
let tsgoInstance = null;
|
|
2269
|
-
if (useTsGo) {
|
|
2270
|
-
tsgoInstance = resolveTsGo(cwd);
|
|
2271
|
-
if (!tsgoInstance) {
|
|
2272
|
-
exit('--tsgo flag was specified but @typescript/native-preview is not installed. Please install it as a dev dependency: pnpm add -D @typescript/native-preview');
|
|
2273
|
-
}
|
|
2274
|
-
}
|
|
2275
2212
|
const tsConfigPath = resolveTsConfigPath(cwd, options.tsconfig);
|
|
2276
|
-
let tsConfig = resolveTsConfig(cwd, tsConfigPath
|
|
2213
|
+
let tsConfig = resolveTsConfig(cwd, tsConfigPath);
|
|
2277
2214
|
let hasTsConfig = Boolean(tsConfig == null ? void 0 : tsConfig.tsConfigPath);
|
|
2278
2215
|
const defaultTsOptions = {
|
|
2279
2216
|
tsConfigPath: tsConfig == null ? void 0 : tsConfig.tsConfigPath,
|
|
@@ -2343,7 +2280,7 @@ async function bundle(cliEntryPath, { cwd: _cwd, onSuccess, ...options } = {}) {
|
|
|
2343
2280
|
// Otherwise, use the existing one.
|
|
2344
2281
|
const defaultTsConfigPath = path.resolve(cwd, 'tsconfig.json');
|
|
2345
2282
|
if (!fileExists(defaultTsConfigPath)) {
|
|
2346
|
-
await writeDefaultTsconfig(defaultTsConfigPath
|
|
2283
|
+
await writeDefaultTsconfig(defaultTsConfigPath);
|
|
2347
2284
|
}
|
|
2348
2285
|
defaultTsOptions.tsConfigPath = defaultTsConfigPath;
|
|
2349
2286
|
hasTsConfig = true;
|
|
@@ -2355,15 +2292,12 @@ async function bundle(cliEntryPath, { cwd: _cwd, onSuccess, ...options } = {}) {
|
|
|
2355
2292
|
const outputState = createOutputState({
|
|
2356
2293
|
entries
|
|
2357
2294
|
});
|
|
2358
|
-
// Use ts-go if it was successfully resolved earlier
|
|
2359
|
-
const useTsGoInContext = Boolean(useTsGo && hasTsConfig && tsgoInstance);
|
|
2360
2295
|
const buildContext = {
|
|
2361
2296
|
entries,
|
|
2362
2297
|
pkg,
|
|
2363
2298
|
cwd,
|
|
2364
2299
|
tsOptions: defaultTsOptions,
|
|
2365
2300
|
useTypeScript: hasTsConfig,
|
|
2366
|
-
useTsGo: useTsGoInContext,
|
|
2367
2301
|
browserslistConfig,
|
|
2368
2302
|
pluginContext: {
|
|
2369
2303
|
outputState,
|