(inputOptions)
| 48 | }; |
| 49 | |
| 50 | export default async function microbundle(inputOptions) { |
| 51 | let options = { ...inputOptions }; |
| 52 | |
| 53 | options.cwd = resolve(process.cwd(), inputOptions.cwd); |
| 54 | const cwd = options.cwd; |
| 55 | |
| 56 | const { hasPackageJson, pkg } = await getConfigFromPkgJson(cwd); |
| 57 | options.pkg = { |
| 58 | ...pkg, |
| 59 | ...pkg.publishConfig, |
| 60 | }; |
| 61 | |
| 62 | const { finalName, pkgName } = getName({ |
| 63 | name: options.name, |
| 64 | pkgName: options.pkg.name, |
| 65 | amdName: options.pkg.amdName, |
| 66 | hasPackageJson, |
| 67 | cwd, |
| 68 | }); |
| 69 | |
| 70 | options.name = finalName; |
| 71 | options.pkg.name = pkgName; |
| 72 | |
| 73 | if (options.sourcemap === 'inline') { |
| 74 | console.log( |
| 75 | 'Warning: inline sourcemaps should only be used for debugging purposes.', |
| 76 | ); |
| 77 | } else if (options.sourcemap === 'false') { |
| 78 | options.sourcemap = false; |
| 79 | } else if (options.sourcemap !== false) { |
| 80 | options.sourcemap = true; |
| 81 | } |
| 82 | |
| 83 | options.input = await getInput({ |
| 84 | entries: options.entries, |
| 85 | cwd, |
| 86 | source: options.pkg.source, |
| 87 | module: options.pkg.module, |
| 88 | }); |
| 89 | |
| 90 | options.output = await getOutput({ |
| 91 | cwd, |
| 92 | output: options.output, |
| 93 | pkgMain: options.pkg.main, |
| 94 | pkgName: options.pkg.name, |
| 95 | }); |
| 96 | |
| 97 | options.entries = await getEntries({ |
| 98 | cwd, |
| 99 | input: options.input, |
| 100 | }); |
| 101 | |
| 102 | options.multipleEntries = options.entries.length > 1; |
| 103 | |
| 104 | let formats = (options.format || options.formats).split(','); |
| 105 | // de-dupe formats and convert "esm" to "es": |
| 106 | formats = Array.from(new Set(formats.map(f => (f === 'esm' ? 'es' : f)))); |
| 107 | // always compile cjs first if it's there: |
no test coverage detected
searching dependent graphs…