mirror of
https://github.com/developit/microbundle.git
synced 2026-01-18 13:56:35 +00:00
Create getOutput function
This commit is contained in:
parent
617c75acfa
commit
b3ec030bb7
19
src/index.js
19
src/index.js
@ -76,11 +76,12 @@ export default async function microbundle(inputOptions) {
|
||||
module: options.pkg.module,
|
||||
});
|
||||
|
||||
let main = resolve(cwd, options.output || options.pkg.main || 'dist');
|
||||
if (!main.match(/\.[a-z]+$/) || (await isDir(main))) {
|
||||
main = resolve(main, `${removeScope(options.pkg.name)}.js`);
|
||||
}
|
||||
options.output = main;
|
||||
options.output = await getOutput({
|
||||
cwd,
|
||||
output: options.output,
|
||||
pkgMain: options.pkg.main,
|
||||
pkgName: options.pkg.name,
|
||||
});
|
||||
|
||||
let entries = (await map([].concat(options.input), async file => {
|
||||
file = resolve(cwd, file);
|
||||
@ -257,6 +258,14 @@ async function getInput({ entries, cwd, source, module }) {
|
||||
return input;
|
||||
}
|
||||
|
||||
async function getOutput({ cwd, output, pkgMain, pkgName }) {
|
||||
let main = resolve(cwd, output || pkgMain || 'dist');
|
||||
if (!main.match(/\.[a-z]+$/) || (await isDir(main))) {
|
||||
main = resolve(main, `${removeScope(pkgName)}.js`);
|
||||
}
|
||||
return main;
|
||||
}
|
||||
|
||||
function createConfig(options, entry, format, writeMeta) {
|
||||
let { pkg } = options;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user