Registry / devops / broccoli-typescript-compiler

broccoli-typescript-compiler

JSON →
library8.0.0jsnpmunverified

Broccoli TypeScript Compiler (broccoli-typescript-compiler) is a specialized Broccoli plugin designed to integrate TypeScript compilation directly into a Broccoli.js build pipeline. Currently stable at version 8.0.0, this package provides robust tooling for converting TypeScript files into JavaScript, supporting both CommonJS and ES modules targets. It allows for flexible configuration via `tsconfig.json` files or inline objects, enabling developers to define compiler options such as module resolution, target ES version, source maps, and declaration file generation. Key differentiators include its tight integration with the Broccoli ecosystem, offering three distinct usage patterns: a direct compilation function, a class-based compiler for more control, and a filter function that intelligently processes only TypeScript files while passing non-TypeScript assets through. While a specific release cadence isn't published, the project actively maintains compatibility with recent TypeScript versions, ensuring it remains a viable solution for Broccoli-based projects requiring TypeScript support.

npm install broccoli-typescript-compiler
INSTALL
IMPORT
SIG · BROCCOLI-TYPESCRIP
B
broccoli-typescript-compiler
devopsjavascriptv8.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import typescript from 'broccoli-typescript-compiler';
const typescript = require('broccoli-typescript-compiler');
The primary function export for direct compilation. CommonJS users should access it via `.default` (e.g., `require('broccoli-typescript-compiler').default`).
TypescriptCompiler
import { TypescriptCompiler } from 'broccoli-typescript-compiler';
const TypescriptCompiler = require('broccoli-typescript-compiler').TypescriptCompiler;
Provides the class-based API for creating a compiler instance. CommonJS users will access it directly as a named export.
filterTypescript
import { filterTypescript } from 'broccoli-typescript-compiler';
const filterTypescript = require('broccoli-typescript-compiler').filterTypescript;
A utility function that compiles only TypeScript files from the input tree and merges them with non-TS files. CommonJS users will access it directly as a named export.

Demonstrates compiling TypeScript files within a Broccoli build, using a custom tsconfig and handling production error settings.

import typescript from 'broccoli-typescript-compiler'; import funnel from 'broccoli-funnel'; import mergeTrees from 'broccoli-merge-trees'; import { createRequire } from 'module'; const require = createRequire(import.meta.url); const inputTree = funnel('.', { exclude: ['node_modules/**', 'dist/**'] }); const compiledJS = typescript(inputTree, { tsconfig: { compilerOptions: { module: 'commonjs', target: 'es2018', moduleResolution: 'node', newLine: 'LF', rootDir: '.', // Assuming root directory outDir: 'dist', sourceMap: true, declaration: true, }, files: ['index.ts', 'src/**/*.ts'], // Adjust files as needed for your project }, throwOnError: process.env.NODE_ENV === 'production', annotation: 'Compile application TypeScript', }); // Example of merging compiled JS with other assets if needed export default mergeTrees([compiledJS /*, otherTrees */], { overwrite: true });
Debug
Known issues
gotchaThe `throwOnError` option defaults to `true` when `process.env.NODE_ENV` is set to 'production', even if explicitly set to `false` in configuration. This can cause unexpected build failures in production environments if not anticipated.
fix
Be aware of the `NODE_ENV` impact. To always allow non-breaking errors regardless of `NODE_ENV`, you may need to explicitly set `throwOnError: false` and ensure `process.env.NODE_ENV` is not 'production' if you intend for errors to be non-fatal.
affects: >=1.0.0
breakingUpgrading the peer dependency `typescript` to a new major version often requires specific maintenance steps, including updating submodules and running `yarn run generate-tsconfig-interface`. Neglecting these steps can lead to compilation issues or incorrect type resolution.
fix
Always follow the 'How to upgrade `typescript`' instructions in the project's README when updating the `typescript` peer dependency. This typically involves `git submodule update --init`, updating `package.json`, running `yarn run generate-tsconfig-interface`, and updating the `vendor/typescript` submodule.
affects: >=1.0.0
gotchaThis package is a Broccoli plugin and is only useful within a Broccoli.js build pipeline. It is not a standalone TypeScript compiler for general-purpose use outside of the Broccoli ecosystem.
fix
Ensure you are integrating this package within a Broccoli.js `Brocfile.js` or a similar Broccoli-managed build process. For standalone TypeScript compilation, use the `typescript` package directly.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'typescript' or its corresponding type declarations.
The `typescript` package, a peer dependency, is not installed or its version does not meet the specified range.
fix
Install the required `typescript` version: `npm install typescript@^4.0.3` (or the version specified in peerDependencies) in your project.
TypeScript compilation failed: [ERROR_MESSAGE]
`throwOnError` is enabled (either explicitly or due to `NODE_ENV='production'`), and TypeScript reported errors during compilation.
fix
Review the `[ERROR_MESSAGE]` output for specific TypeScript errors. Fix the TypeScript code issues, or set `throwOnError: false` (being mindful of the `NODE_ENV` default override) if you want to allow the build to proceed with errors.
Error: The 'tsconfig' option must be a string path or a config object.
The `tsconfig` option was provided in an incorrect format or was missing required properties.
fix
Ensure `tsconfig` is either an absolute path string to a `tsconfig.json` file or a valid JavaScript object matching the structure of `tsconfig.json`'s `compilerOptions` and other root-level properties.
Upgrade
Version history
8.0.0latest on npm
Audit
Dependencies
typescriptrequiredRequired for TypeScript compilation. Must be installed as a peer dependency.
Agent activity
25 hits · last 30 days
node
22
OpenAI (training)
2
Amazon
1
Resources
broccoli-typescript-compiler — npm install broccoli-typescript-compiler · libregistry