Merge pull request #176 from gribnoysup/fix/cwd-with-custom-source

Fix issue when using cwd and package.source
This commit is contained in:
Leah 2018-07-29 22:25:03 +02:00 committed by GitHub
commit 40a7d28fe2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 127 additions and 1 deletions

View File

@ -94,7 +94,7 @@ export default async function microbundle(options) {
.concat(
options.entries && options.entries.length
? options.entries
: options.pkg.source ||
: (options.pkg.source && resolve(cwd, options.pkg.source)) ||
((await isDir(resolve(cwd, 'src'))) && (await jsOrTs('src/index'))) ||
(await jsOrTs('index')) ||
options.pkg.module,

View File

@ -105,6 +105,85 @@ Build \\"basicLibTsx\\" to dist:
295 B: basic-lib-tsx.umd.js"
`;
exports[`fixtures basic-with-cwd 1`] = `
"Used script: microbundle --cwd ./basic
Directory tree:
basic-with-cwd
basic
dist
basic.js
basic.js.map
basic.mjs
basic.mjs.map
basic.umd.js
basic.umd.js.map
package.json
src
index.js
two.js
package.json
Build \\"basic\\" to dist:
211 B: basic.js
211 B: basic.mjs
287 B: basic.umd.js"
`;
exports[`fixtures custom-source 1`] = `
"Used script: microbundle
Directory tree:
custom-source
dist
custom-source.js
custom-source.js.map
custom-source.mjs
custom-source.mjs.map
custom-source.umd.js
custom-source.umd.js.map
package.json
src
custom-source.js
two.js
Build \\"customSource\\" to dist:
211 B: custom-source.js
211 B: custom-source.mjs
293 B: custom-source.umd.js"
`;
exports[`fixtures custom-source-with-cwd 1`] = `
"Used script: microbundle --cwd ./custom-source
Directory tree:
custom-source-with-cwd
custom-source
dist
custom-src.js
custom-src.js.map
custom-src.mjs
custom-src.mjs.map
custom-src.umd.js
custom-src.umd.js.map
package.json
src
custom-source.js
two.js
package.json
Build \\"customSrc\\" to dist:
211 B: custom-src.js
211 B: custom-src.mjs
291 B: custom-src.umd.js"
`;
exports[`fixtures jsx 1`] = `
"Used script: microbundle

View File

@ -0,0 +1,3 @@
{
"name": "basic"
}

View File

@ -0,0 +1,5 @@
import { two } from './two';
export default async function(...args) {
return [await two(...args), await two(...args)];
}

View File

@ -0,0 +1,3 @@
export async function two(...args) {
return args.reduce((total, value) => total + value, 0);
}

View File

@ -0,0 +1,6 @@
{
"name": "basic-with-cwd",
"scripts": {
"build": "microbundle --cwd ./basic"
}
}

View File

@ -0,0 +1,4 @@
{
"name": "custom-src",
"source": "src/custom-source.js"
}

View File

@ -0,0 +1,5 @@
import { two } from './two';
export default async function(...args) {
return [await two(...args), await two(...args)];
}

View File

@ -0,0 +1,3 @@
export async function two(...args) {
return args.reduce((total, value) => total + value, 0);
}

View File

@ -0,0 +1,6 @@
{
"name": "custom-source-with-cwd",
"scripts": {
"build": "microbundle --cwd ./custom-source"
}
}

View File

@ -0,0 +1,4 @@
{
"name": "custom-source",
"source": "src/custom-source.js"
}

View File

@ -0,0 +1,5 @@
import { two } from './two';
export default async function(...args) {
return [await two(...args), await two(...args)];
}

View File

@ -0,0 +1,3 @@
export async function two(...args) {
return args.reduce((total, value) => total + value, 0);
}