[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.

fix: don't use `.flat()` (to support node 10)

Daniel Roe (Nov 24, 2020, 9:38 AM UTC) c816faab 2eb31c34

+15 -5
+2 -5
src/core/package/index.ts
··· 29 29 RequireProperties, 30 30 } from '../utils' 31 31 import type { PackageJson } from './types' 32 - import { getEntrypointFilenames } from './utils' 32 + import { getEntrypointFilenames, getFlatValues } from './utils' 33 33 34 34 export interface DefaultPackageOptions { 35 35 /** ··· 400 400 if (typeof exports === 'string') return [exports].filter(filterExports) 401 401 if (Array.isArray(exports)) return exports.filter(filterExports) 402 402 403 - return Object.values(exports) 404 - .map(ex => (typeof ex === 'string' ? ex : Object.values(ex))) 405 - .flat() 406 - .filter(filterExports) 403 + return getFlatValues(exports).filter(filterExports) 407 404 } 408 405 409 406 /**
+13
src/core/package/utils.ts
··· 1 1 import { basename } from 'path' 2 + import type { PackageJson } from './types' 2 3 3 4 export const getEntrypointFilenames = (path: string) => { 4 5 if (path.startsWith('./')) path = path.slice(2) ··· 21 22 }, [] as string[]) 22 23 23 24 return filenames 25 + } 26 + 27 + export const getFlatValues = ( 28 + obj: Exclude<PackageJson['exports'], string | undefined> 29 + ) => { 30 + return Object.values(obj) 31 + .map(ex => (typeof ex === 'string' ? ex : Object.values(ex))) 32 + .reduce((flatArray: string[], item) => { 33 + if (Array.isArray(item)) return [...flatArray, ...item] 34 + flatArray.push(item) 35 + return flatArray 36 + }, []) 24 37 }