chore: fix CI with new typescript setup (#1194)
Co-authored-by: Ralph Khreish <Crunchyman-ralph@users.noreply.github.com> Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
This commit is contained in:
31
packages/build-config/package.json
Normal file
31
packages/build-config/package.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "@tm/build-config",
|
||||
"version": "1.0.0",
|
||||
"description": "Shared build configuration for Task Master monorepo",
|
||||
"type": "module",
|
||||
"main": "./dist/tsup.base.js",
|
||||
"types": "./dist/tsup.base.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./src/tsup.base.ts",
|
||||
"import": "./dist/tsup.base.js",
|
||||
"require": "./dist/tsup.base.cjs"
|
||||
}
|
||||
},
|
||||
"files": ["dist", "src"],
|
||||
"keywords": ["build-config", "tsup", "monorepo"],
|
||||
"author": "",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"build": "tsup",
|
||||
"dev": "tsup --watch",
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tsup": "^8.5.0",
|
||||
"typescript": "^5.7.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"tsup": "^8.0.0"
|
||||
}
|
||||
}
|
||||
151
packages/build-config/src/tsup.base.ts
Normal file
151
packages/build-config/src/tsup.base.ts
Normal file
@@ -0,0 +1,151 @@
|
||||
/**
|
||||
* Base tsup configuration for Task Master monorepo
|
||||
* Provides shared configuration that can be extended by individual packages
|
||||
*/
|
||||
import type { Options } from 'tsup';
|
||||
|
||||
const isProduction = process.env.NODE_ENV === 'production';
|
||||
const isDevelopment = !isProduction;
|
||||
|
||||
/**
|
||||
* Base configuration for library packages (tm-core, etc.)
|
||||
*/
|
||||
export const libraryConfig: Partial<Options> = {
|
||||
format: ['cjs', 'esm'],
|
||||
target: 'es2022',
|
||||
// Sourcemaps only in development to reduce production bundle size
|
||||
sourcemap: isDevelopment,
|
||||
clean: true,
|
||||
dts: true,
|
||||
// Enable optimizations in production
|
||||
splitting: isProduction,
|
||||
treeshake: isProduction,
|
||||
minify: isProduction,
|
||||
bundle: true,
|
||||
esbuildOptions(options) {
|
||||
options.conditions = ['module'];
|
||||
// Better source mapping in development only
|
||||
options.sourcesContent = isDevelopment;
|
||||
// Keep original names for better debugging in development
|
||||
options.keepNames = isDevelopment;
|
||||
},
|
||||
// Watch mode configuration for development
|
||||
watch: isDevelopment ? ['src'] : false
|
||||
};
|
||||
|
||||
/**
|
||||
* Base configuration for CLI packages
|
||||
*/
|
||||
export const cliConfig: Partial<Options> = {
|
||||
format: ['esm'],
|
||||
target: 'node18',
|
||||
splitting: false,
|
||||
// Sourcemaps only in development to reduce production bundle size
|
||||
sourcemap: isDevelopment,
|
||||
clean: true,
|
||||
dts: true,
|
||||
shims: true,
|
||||
// Enable minification in production for smaller bundles
|
||||
minify: isProduction,
|
||||
treeshake: isProduction,
|
||||
esbuildOptions(options) {
|
||||
options.platform = 'node';
|
||||
// Better source mapping in development only
|
||||
options.sourcesContent = isDevelopment;
|
||||
// Keep original names for better debugging in development
|
||||
options.keepNames = isDevelopment;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Base configuration for executable bundles (root level)
|
||||
*/
|
||||
export const executableConfig: Partial<Options> = {
|
||||
format: ['esm'],
|
||||
target: 'node18',
|
||||
splitting: false,
|
||||
// Sourcemaps only in development to reduce production bundle size
|
||||
sourcemap: isDevelopment,
|
||||
clean: true,
|
||||
bundle: true, // Bundle everything into one file
|
||||
// Minify in production for smaller executables
|
||||
minify: isProduction,
|
||||
// Handle TypeScript imports transparently
|
||||
loader: {
|
||||
'.js': 'jsx',
|
||||
'.ts': 'ts'
|
||||
},
|
||||
esbuildOptions(options) {
|
||||
options.platform = 'node';
|
||||
// Allow importing TypeScript from JavaScript
|
||||
options.resolveExtensions = ['.ts', '.js', '.mjs', '.json'];
|
||||
// Better source mapping in development only
|
||||
options.sourcesContent = isDevelopment;
|
||||
// Keep original names for better debugging in development
|
||||
options.keepNames = isDevelopment;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Common external modules that should not be bundled
|
||||
*/
|
||||
export const commonExternals = [
|
||||
// Native Node.js modules
|
||||
'fs',
|
||||
'path',
|
||||
'child_process',
|
||||
'crypto',
|
||||
'os',
|
||||
'url',
|
||||
'util',
|
||||
'stream',
|
||||
'http',
|
||||
'https',
|
||||
'events',
|
||||
'assert',
|
||||
'buffer',
|
||||
'querystring',
|
||||
'readline',
|
||||
'zlib',
|
||||
'tty',
|
||||
'net',
|
||||
'dgram',
|
||||
'dns',
|
||||
'tls',
|
||||
'cluster',
|
||||
'process',
|
||||
'module'
|
||||
];
|
||||
|
||||
/**
|
||||
* Utility function to merge configurations
|
||||
*/
|
||||
export function mergeConfig(
|
||||
baseConfig: Partial<Options>,
|
||||
overrides: Partial<Options>
|
||||
): Options {
|
||||
return {
|
||||
...baseConfig,
|
||||
...overrides,
|
||||
// Merge arrays instead of overwriting
|
||||
external: [...(baseConfig.external || []), ...(overrides.external || [])],
|
||||
// Merge esbuildOptions
|
||||
esbuildOptions(options, context) {
|
||||
if (baseConfig.esbuildOptions) {
|
||||
baseConfig.esbuildOptions(options, context);
|
||||
}
|
||||
if (overrides.esbuildOptions) {
|
||||
overrides.esbuildOptions(options, context);
|
||||
}
|
||||
}
|
||||
} as Options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Environment helpers
|
||||
*/
|
||||
export const env = {
|
||||
isProduction,
|
||||
isDevelopment,
|
||||
NODE_ENV: process.env.NODE_ENV || 'development'
|
||||
};
|
||||
20
packages/build-config/tsconfig.json
Normal file
20
packages/build-config/tsconfig.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"lib": ["ES2022"],
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"esModuleInterop": true,
|
||||
"allowJs": true,
|
||||
"strict": true,
|
||||
"noEmit": true,
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"declaration": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
||||
23
packages/build-config/tsup.config.ts
Normal file
23
packages/build-config/tsup.config.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { defineConfig } from 'tsup';
|
||||
|
||||
const isProduction = process.env.NODE_ENV === 'production';
|
||||
|
||||
export default defineConfig({
|
||||
entry: ['src/tsup.base.ts'],
|
||||
format: ['esm', 'cjs'],
|
||||
target: 'node18',
|
||||
// Sourcemaps only in development
|
||||
sourcemap: !isProduction,
|
||||
clean: true,
|
||||
dts: true,
|
||||
// Enable minification in production
|
||||
minify: isProduction,
|
||||
treeshake: isProduction,
|
||||
external: ['tsup'],
|
||||
esbuildOptions(options) {
|
||||
// Better source mapping in development only
|
||||
options.sourcesContent = !isProduction;
|
||||
// Keep original names for better debugging in development
|
||||
options.keepNames = !isProduction;
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user