From 581c1fcb0e9bbfba901af63e8c3c8c74bbd0dd6a Mon Sep 17 00:00:00 2001 From: maxwell8888 Date: Thu, 3 Sep 2020 15:15:34 +0100 Subject: [PATCH] Fix api docs loadconfigfile (#3757) * fix api docs for loadConfigFile * fix linting * fix to use optionsObj not options * fix text to say objects not object --- docs/02-javascript-api.md | 43 +++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/docs/02-javascript-api.md b/docs/02-javascript-api.md index 483f7ce9020..7357ee457b6 100755 --- a/docs/02-javascript-api.md +++ b/docs/02-javascript-api.md @@ -213,23 +213,26 @@ const rollup = require('rollup'); // load the config file next to the current script; // the provided config object has the same effect as passing "--format es" // on the command line and will override the format of all outputs -loadConfigFile(path.resolve(__dirname, 'rollup.config.js'), { format: 'es' }) - .then(async ({options, warnings}) => { - // "warnings" wraps the default `onwarn` handler passed by the CLI. - // This prints all warnings up to this point: - console.log(`We currently have ${warnings.count} warnings`); - - // This prints all deferred warnings - warnings.flush(); - - // options is an "inputOptions" object with an additional "output" - // property that contains an array of "outputOptions". - // The following will generate all outputs and write them to disk the same - // way the CLI does it: - const bundle = await rollup.rollup(options); - await Promise.all(options.output.map(bundle.write)); - - // You can also pass this directly to "rollup.watch" - rollup.watch(options); - }) -``` +loadConfigFile(path.resolve(__dirname, 'rollup.config.js'), { format: 'es' }).then( + async ({ options, warnings }) => { + // "warnings" wraps the default `onwarn` handler passed by the CLI. + // This prints all warnings up to this point: + console.log(`We currently have ${warnings.count} warnings`); + + // This prints all deferred warnings + warnings.flush(); + + // options is an array of "inputOptions" objects with an additional "output" + // property that contains an array of "outputOptions". + // The following will generate all outputs for all inputs, and write them to disk the same + // way the CLI does it: + for (const optionsObj of options) { + const bundle = await rollup.rollup(optionsObj); + await Promise.all(optionsObj.output.map(bundle.write)); + } + + // You can also pass this directly to "rollup.watch" + rollup.watch(options); + } +); +``` \ No newline at end of file