From 57cfaa0353477c0c2d3cecb4215b62ab6d405f8d Mon Sep 17 00:00:00 2001 From: Max U Date: Wed, 2 Sep 2020 17:03:36 +0100 Subject: [PATCH 1/4] fix api docs for loadConfigFile --- docs/02-javascript-api.md | 191 +++++++++++++++++++------------------- 1 file changed, 97 insertions(+), 94 deletions(-) diff --git a/docs/02-javascript-api.md b/docs/02-javascript-api.md index 483f7ce9020..eb67116b48e 100755 --- a/docs/02-javascript-api.md +++ b/docs/02-javascript-api.md @@ -80,29 +80,29 @@ The `inputOptions` object can contain the following properties (see the [big lis ```js const inputOptions = { - // core input options - external, - input, // condtionally required - plugins, - - // advanced input options - cache, - onwarn, - preserveEntrySignatures, - strictDeprecations, - - // danger zone - acorn, - acornInjectPlugins, - context, - moduleContext, - preserveSymlinks, - shimMissingExports, - treeshake, - - // experimental - experimentalCacheExpiry, - perf + // core input options + external, + input, // condtionally required + plugins, + + // advanced input options + cache, + onwarn, + preserveEntrySignatures, + strictDeprecations, + + // danger zone + acorn, + acornInjectPlugins, + context, + moduleContext, + preserveSymlinks, + shimMissingExports, + treeshake, + + // experimental + experimentalCacheExpiry, + perf }; ``` @@ -112,48 +112,48 @@ The `outputOptions` object can contain the following properties (see the [big li ```js const outputOptions = { - // core output options - dir, - file, - format, // required - globals, - name, - plugins, - - // advanced output options - assetFileNames, - banner, - chunkFileNames, - compact, - entryFileNames, - extend, - externalLiveBindings, - footer, - hoistTransitiveImports, - inlineDynamicImports, - interop, - intro, - manualChunks, - minifyInternalExports, - outro, - paths, - preserveModules, - sourcemap, - sourcemapExcludeSources, - sourcemapFile, - sourcemapPathTransform, - - // danger zone - amd, - esModule, - exports, - freeze, - indent, - namespaceToStringTag, - noConflict, - preferConst, - strict, - systemNullSetters + // core output options + dir, + file, + format, // required + globals, + name, + plugins, + + // advanced output options + assetFileNames, + banner, + chunkFileNames, + compact, + entryFileNames, + extend, + externalLiveBindings, + footer, + hoistTransitiveImports, + inlineDynamicImports, + interop, + intro, + manualChunks, + minifyInternalExports, + outro, + paths, + preserveModules, + sourcemap, + sourcemapExcludeSources, + sourcemapFile, + sourcemapPathTransform, + + // danger zone + amd, + esModule, + exports, + freeze, + indent, + namespaceToStringTag, + noConflict, + preferConst, + strict, + systemNullSetters }; ``` @@ -186,16 +186,16 @@ The `watchOptions` argument is a config (or an array of configs) that you would ```js const watchOptions = { - ...inputOptions, - output: [outputOptions], - watch: { - buildDelay, - chokidar, - clearScreen, - skipWrite, - exclude, - include - } + ...inputOptions, + output: [outputOptions], + watch: { + buildDelay, + chokidar, + clearScreen, + skipWrite, + exclude, + include + } }; ``` @@ -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" object 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(options); + await Promise.all(options.output.map(bundle.write)); + } + + // You can also pass this directly to "rollup.watch" + rollup.watch(options); + } +); ``` From 273ea908e69b6cbf5b92e5c671e26ca72ec0f38a Mon Sep 17 00:00:00 2001 From: Max U Date: Wed, 2 Sep 2020 17:11:19 +0100 Subject: [PATCH 2/4] fix linting --- docs/02-javascript-api.md | 152 +++++++++++++++++++------------------- 1 file changed, 76 insertions(+), 76 deletions(-) diff --git a/docs/02-javascript-api.md b/docs/02-javascript-api.md index eb67116b48e..1cf8654d831 100755 --- a/docs/02-javascript-api.md +++ b/docs/02-javascript-api.md @@ -80,29 +80,29 @@ The `inputOptions` object can contain the following properties (see the [big lis ```js const inputOptions = { - // core input options - external, - input, // condtionally required - plugins, - - // advanced input options - cache, - onwarn, - preserveEntrySignatures, - strictDeprecations, - - // danger zone - acorn, - acornInjectPlugins, - context, - moduleContext, - preserveSymlinks, - shimMissingExports, - treeshake, - - // experimental - experimentalCacheExpiry, - perf + // core input options + external, + input, // condtionally required + plugins, + + // advanced input options + cache, + onwarn, + preserveEntrySignatures, + strictDeprecations, + + // danger zone + acorn, + acornInjectPlugins, + context, + moduleContext, + preserveSymlinks, + shimMissingExports, + treeshake, + + // experimental + experimentalCacheExpiry, + perf }; ``` @@ -112,48 +112,48 @@ The `outputOptions` object can contain the following properties (see the [big li ```js const outputOptions = { - // core output options - dir, - file, - format, // required - globals, - name, - plugins, - - // advanced output options - assetFileNames, - banner, - chunkFileNames, - compact, - entryFileNames, - extend, - externalLiveBindings, - footer, - hoistTransitiveImports, - inlineDynamicImports, - interop, - intro, - manualChunks, - minifyInternalExports, - outro, - paths, - preserveModules, - sourcemap, - sourcemapExcludeSources, - sourcemapFile, - sourcemapPathTransform, - - // danger zone - amd, - esModule, - exports, - freeze, - indent, - namespaceToStringTag, - noConflict, - preferConst, - strict, - systemNullSetters + // core output options + dir, + file, + format, // required + globals, + name, + plugins, + + // advanced output options + assetFileNames, + banner, + chunkFileNames, + compact, + entryFileNames, + extend, + externalLiveBindings, + footer, + hoistTransitiveImports, + inlineDynamicImports, + interop, + intro, + manualChunks, + minifyInternalExports, + outro, + paths, + preserveModules, + sourcemap, + sourcemapExcludeSources, + sourcemapFile, + sourcemapPathTransform, + + // danger zone + amd, + esModule, + exports, + freeze, + indent, + namespaceToStringTag, + noConflict, + preferConst, + strict, + systemNullSetters }; ``` @@ -186,16 +186,16 @@ The `watchOptions` argument is a config (or an array of configs) that you would ```js const watchOptions = { - ...inputOptions, - output: [outputOptions], - watch: { - buildDelay, - chokidar, - clearScreen, - skipWrite, - exclude, - include - } + ...inputOptions, + output: [outputOptions], + watch: { + buildDelay, + chokidar, + clearScreen, + skipWrite, + exclude, + include + } }; ``` @@ -235,4 +235,4 @@ loadConfigFile(path.resolve(__dirname, 'rollup.config.js'), { format: 'es' }).th rollup.watch(options); } ); -``` +``` \ No newline at end of file From 706fccc22a2e27e5767ef8eae0ce4ccd155aa491 Mon Sep 17 00:00:00 2001 From: Max U Date: Wed, 2 Sep 2020 17:14:05 +0100 Subject: [PATCH 3/4] fix to use optionsObj not options --- docs/02-javascript-api.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/02-javascript-api.md b/docs/02-javascript-api.md index 1cf8654d831..f1ce7d44978 100755 --- a/docs/02-javascript-api.md +++ b/docs/02-javascript-api.md @@ -227,8 +227,8 @@ loadConfigFile(path.resolve(__dirname, 'rollup.config.js'), { format: 'es' }).th // 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(options); - await Promise.all(options.output.map(bundle.write)); + const bundle = await rollup.rollup(optionsObj); + await Promise.all(optionsObj.output.map(bundle.write)); } // You can also pass this directly to "rollup.watch" From 44c0bff6ab0d514c3336d5671885d1e078968583 Mon Sep 17 00:00:00 2001 From: Max U Date: Wed, 2 Sep 2020 17:15:14 +0100 Subject: [PATCH 4/4] fix text to say objects not object --- docs/02-javascript-api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/02-javascript-api.md b/docs/02-javascript-api.md index f1ce7d44978..7357ee457b6 100755 --- a/docs/02-javascript-api.md +++ b/docs/02-javascript-api.md @@ -222,7 +222,7 @@ loadConfigFile(path.resolve(__dirname, 'rollup.config.js'), { format: 'es' }).th // This prints all deferred warnings warnings.flush(); - // options is an array of "inputOptions" object with an additional "output" + // 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: