(
bundle: Bundle,
options: OutputOptions,
log: (x: string) => {},
)
| 41 | } |
| 42 | |
| 43 | function saveBundleAndMap( |
| 44 | bundle: Bundle, |
| 45 | options: OutputOptions, |
| 46 | log: (x: string) => {}, |
| 47 | ): Promise<> { |
| 48 | const { |
| 49 | bundleOutput, |
| 50 | bundleEncoding: encoding, |
| 51 | dev, |
| 52 | sourcemapOutput, |
| 53 | sourcemapSourcesRoot |
| 54 | } = options; |
| 55 | |
| 56 | log('start'); |
| 57 | const codeWithMap = createCodeWithMap(bundle, !!dev, sourcemapSourcesRoot); |
| 58 | log('finish'); |
| 59 | |
| 60 | log('Writing bundle output to:', bundleOutput); |
| 61 | |
| 62 | const {code} = codeWithMap; |
| 63 | const writeBundle = writeFile(bundleOutput, code, encoding); |
| 64 | const writeMetadata = writeFile( |
| 65 | bundleOutput + '.meta', |
| 66 | meta(code, encoding), |
| 67 | 'binary'); |
| 68 | Promise.all([writeBundle, writeMetadata]) |
| 69 | .then(() => log('Done writing bundle output')); |
| 70 | |
| 71 | if (sourcemapOutput) { |
| 72 | log('Writing sourcemap output to:', sourcemapOutput); |
| 73 | const writeMap = writeFile(sourcemapOutput, codeWithMap.map, null); |
| 74 | writeMap.then(() => log('Done writing sourcemap output')); |
| 75 | return Promise.all([writeBundle, writeMetadata, writeMap]); |
| 76 | } else { |
| 77 | return writeBundle; |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | exports.build = buildBundle; |
| 82 | exports.save = saveBundleAndMap; |
nothing calls this directly
no test coverage detected
searching dependent graphs…