[READ-ONLY] Mirror of https://github.com/danielroe/siroc. Zero-config build tooling for Node
bundle node package rollup typescript
0

Configure Feed

Select the types of activity you want to include in your feed.

feat: add optional logging of entry -> output

* use with: `CONSOLA_LEVEL=4`

closes #192

Daniel Roe (Nov 29, 2020, 4:10 PM UTC) ee95d8d2 be6f6c99

+39 -5
+3 -1
src/core/build/index.ts
··· 12 12 runInParallel, 13 13 RequireProperties, 14 14 } from '../utils' 15 - import { getRollupConfig, BuildConfigOptions } from './rollup' 15 + import { getRollupConfig, BuildConfigOptions, logRollupConfig } from './rollup' 16 16 17 17 export * from './hooks' 18 18 export * from './rollup' ··· 67 67 await pkg.callHook('build:extendRollup', { 68 68 rollupConfig, 69 69 }) 70 + 71 + logRollupConfig(pkg, rollupConfig) 70 72 71 73 if (shouldWatch) { 72 74 // Watch
+36 -4
src/core/build/rollup.ts
··· 1 - import { resolve, basename } from 'path' 1 + import { resolve, basename, relative } from 'path' 2 2 3 3 import aliasPlugin from '@rollup/plugin-alias' 4 4 import commonjsPlugin from '@rollup/plugin-commonjs' ··· 7 7 import nodeResolvePlugin, { 8 8 RollupNodeResolveOptions, 9 9 } from '@rollup/plugin-node-resolve' 10 + import chalk from 'chalk' 10 11 import defu from 'defu' 11 12 import type { RollupOptions, OutputOptions } from 'rollup' 12 13 import dts from 'rollup-plugin-dts' ··· 129 130 ] 130 131 131 132 return [ 132 - ...binaries.map(([binary, input]) => { 133 - return defu({}, options as RollupOptions, { 133 + ...binaries.map(([binary, input]) => 134 + defu({}, options as RollupOptions, { 134 135 input, 135 136 output: { 136 137 ...getFilenames(binary, '', 'cjs'), ··· 141 142 external, 142 143 plugins: getPlugins(), 143 144 }) 144 - }), 145 + ), 145 146 ...includeIf(input, input => 146 147 defu({}, options as RollupOptions, { 147 148 input, ··· 188 189 }) 189 190 ), 190 191 ] 192 + } 193 + 194 + function hl(str: string) { 195 + return chalk.green(str) 196 + } 197 + 198 + function prettyPath(p: string, highlight = true) { 199 + p = relative(process.cwd(), p) 200 + return highlight ? hl(p) : p 201 + } 202 + 203 + export const logRollupConfig = (pkg: Package, config: RollupOptions[]) => { 204 + config.forEach(item => { 205 + const input = 206 + typeof item.input === 'string' 207 + ? prettyPath(item.input, false).padEnd(30) + ' → ' 208 + : item.input 209 + const output = Array.isArray(item.output) ? item.output : [item.output] 210 + output.forEach(out => { 211 + const outfile = 212 + out?.file || 213 + (out?.dir ? out.dir + '/' : '') + String(out?.entryFileNames) || 214 + '' 215 + const format = outfile.endsWith('.d.ts') 216 + ? '(dts)' 217 + : out?.format 218 + ? `(${out.format})` 219 + : '' 220 + pkg.logger.debug(input, prettyPath(outfile), format) 221 + }) 222 + }) 191 223 }