@ts-bridge/cli
Advanced tools
Comparing version
@@ -10,2 +10,8 @@ # Changelog | ||
## [0.4.2] | ||
### Fixed | ||
- Fix building subset of project references ([#43](https://github.com/ts-bridge/ts-bridge/pull/43)) | ||
## [0.4.1] | ||
@@ -107,3 +113,4 @@ | ||
[Unreleased]: https://github.com/ts-bridge/ts-bridge/compare/@ts-bridge/cli@0.4.1...HEAD | ||
[Unreleased]: https://github.com/ts-bridge/ts-bridge/compare/@ts-bridge/cli@0.4.2...HEAD | ||
[0.4.2]: https://github.com/ts-bridge/ts-bridge/compare/@ts-bridge/cli@0.4.1...@ts-bridge/cli@0.4.2 | ||
[0.4.1]: https://github.com/ts-bridge/ts-bridge/compare/@ts-bridge/cli@0.4.0...@ts-bridge/cli@0.4.1 | ||
@@ -110,0 +117,0 @@ [0.4.0]: https://github.com/ts-bridge/ts-bridge/compare/@ts-bridge/cli@0.3.0...@ts-bridge/cli@0.4.0 |
@@ -110,11 +110,4 @@ import type { CompilerHost, CompilerOptions, ParsedCommandLine, Program, ProjectReference, System } from 'typescript'; | ||
* @param options - The build options. | ||
* @param options.program - The base TypeScript program to use. | ||
* @param options.format - The formats to build. | ||
* @param options.system - The file system to use. | ||
* @param options.baseDirectory - The base directory of the project. | ||
* @param options.verbose - Whether to enable verbose logging. | ||
* @param options.shims - Whether to generate shims for environment-specific | ||
* APIs. | ||
*/ | ||
export declare function buildProjectReferences({ program, format, system, baseDirectory, verbose, shims, }: BuilderOptions): void; | ||
export declare function buildProjectReferences(options: BuilderOptions): void; | ||
/** | ||
@@ -121,0 +114,0 @@ * Get the build function to use based on the TypeScript configuration. This |
@@ -58,2 +58,24 @@ import chalk from 'chalk'; | ||
/** | ||
* Get the initial compiler host to use for the build. This function will return | ||
* the host to use based on the build options. | ||
* | ||
* @param options - The options. | ||
* @param options.format - The formats to build. | ||
* @param options.compilerOptions - The compiler options to use. | ||
* @param options.system - The file system to use. | ||
* @param options.projectReferences - The project references to use. | ||
* @returns The initial compiler host to use for the build. | ||
*/ | ||
function getInitialCompilerHost({ format, compilerOptions, system, projectReferences, }) { | ||
if (getDefinedArray(projectReferences).length === 0) { | ||
return undefined; | ||
} | ||
const mockProgram = createProgram({ | ||
rootNames: [], | ||
options: {}, | ||
projectReferences, | ||
}); | ||
return createProjectReferencesCompilerHost(format, compilerOptions, getDefinedArray(mockProgram.getResolvedProjectReferences()), system); | ||
} | ||
/** | ||
* Handle the `build` command. This is intended to be called by the CLI. | ||
@@ -64,3 +86,3 @@ * | ||
export function buildHandler(options) { | ||
const { format, project, files: customFiles, clean, system, host, verbose, references, shims = true, } = options; | ||
const { format, project, files: customFiles, clean, system, verbose, references, shims = true, } = options; | ||
const tsConfig = getTypeScriptConfig(project, system); | ||
@@ -73,2 +95,8 @@ const baseOptions = getBaseCompilerOptions(dirname(project), tsConfig.options); | ||
const files = getFiles(customFiles, tsConfig.fileNames); | ||
const initialHost = getInitialCompilerHost({ | ||
format, | ||
compilerOptions: baseOptions, | ||
system, | ||
projectReferences: tsConfig.projectReferences, | ||
}); | ||
const compilerOptions = getCompilerOptions(baseOptions); | ||
@@ -78,3 +106,3 @@ const program = getProgram({ | ||
files, | ||
host, | ||
host: initialHost, | ||
projectReferences: tsConfig.projectReferences, | ||
@@ -89,3 +117,2 @@ }); | ||
system, | ||
host, | ||
baseDirectory, | ||
@@ -211,11 +238,5 @@ tsConfig, | ||
* @param options - The build options. | ||
* @param options.program - The base TypeScript program to use. | ||
* @param options.format - The formats to build. | ||
* @param options.system - The file system to use. | ||
* @param options.baseDirectory - The base directory of the project. | ||
* @param options.verbose - Whether to enable verbose logging. | ||
* @param options.shims - Whether to generate shims for environment-specific | ||
* APIs. | ||
*/ | ||
export function buildProjectReferences({ program, format, system, baseDirectory, verbose, shims, }) { | ||
export function buildProjectReferences(options) { | ||
const { program, tsConfig, format, system, baseDirectory, verbose, shims } = options; | ||
const resolvedProjectReferences = getDefinedArray(program.getResolvedProjectReferences()); | ||
@@ -252,2 +273,5 @@ const sortedProjectReferences = getResolvedProjectReferences(baseDirectory, resolvedProjectReferences); | ||
} | ||
info('All project references built. Building main project.'); | ||
const buildFunction = getBuildFunction(tsConfig, false); | ||
buildFunction(options); | ||
} | ||
@@ -254,0 +278,0 @@ /** |
@@ -319,2 +319,8 @@ import { getFixture, noOp, parseJson } from '@ts-bridge/test-utils'; | ||
'packages/project-2/dist/index.d.cts', | ||
'dist/index.mjs', | ||
'dist/index.d.mts.map', | ||
'dist/index.d.mts', | ||
'dist/index.cjs', | ||
'dist/index.d.cts.map', | ||
'dist/index.d.cts', | ||
]); | ||
@@ -365,2 +371,8 @@ }); | ||
'packages/project-2/dist/index.d.cts', | ||
'dist/index.mjs', | ||
'dist/index.d.mts.map', | ||
'dist/index.d.mts', | ||
'dist/index.cjs', | ||
'dist/index.d.cts.map', | ||
'dist/index.d.cts', | ||
]); | ||
@@ -367,0 +379,0 @@ }); |
{ | ||
"name": "@ts-bridge/cli", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"description": "Bridge the gap between ES modules and CommonJS modules with an easy-to-use alternative to `tsc`.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
297443
0.37%6614
0.44%