mirror of
https://github.com/developit/microbundle.git
synced 2026-01-25 14:06:50 +00:00
Merge pull request #176 from gribnoysup/fix/cwd-with-custom-source
Fix issue when using cwd and package.source
This commit is contained in:
commit
40a7d28fe2
@ -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,
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
3
test/fixtures/basic-with-cwd/basic/package.json
vendored
Normal file
3
test/fixtures/basic-with-cwd/basic/package.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"name": "basic"
|
||||
}
|
||||
5
test/fixtures/basic-with-cwd/basic/src/index.js
vendored
Normal file
5
test/fixtures/basic-with-cwd/basic/src/index.js
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
import { two } from './two';
|
||||
|
||||
export default async function(...args) {
|
||||
return [await two(...args), await two(...args)];
|
||||
}
|
||||
3
test/fixtures/basic-with-cwd/basic/src/two.js
vendored
Normal file
3
test/fixtures/basic-with-cwd/basic/src/two.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
export async function two(...args) {
|
||||
return args.reduce((total, value) => total + value, 0);
|
||||
}
|
||||
6
test/fixtures/basic-with-cwd/package.json
vendored
Normal file
6
test/fixtures/basic-with-cwd/package.json
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "basic-with-cwd",
|
||||
"scripts": {
|
||||
"build": "microbundle --cwd ./basic"
|
||||
}
|
||||
}
|
||||
4
test/fixtures/custom-source-with-cwd/custom-source/package.json
vendored
Normal file
4
test/fixtures/custom-source-with-cwd/custom-source/package.json
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "custom-src",
|
||||
"source": "src/custom-source.js"
|
||||
}
|
||||
5
test/fixtures/custom-source-with-cwd/custom-source/src/custom-source.js
vendored
Normal file
5
test/fixtures/custom-source-with-cwd/custom-source/src/custom-source.js
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
import { two } from './two';
|
||||
|
||||
export default async function(...args) {
|
||||
return [await two(...args), await two(...args)];
|
||||
}
|
||||
3
test/fixtures/custom-source-with-cwd/custom-source/src/two.js
vendored
Normal file
3
test/fixtures/custom-source-with-cwd/custom-source/src/two.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
export async function two(...args) {
|
||||
return args.reduce((total, value) => total + value, 0);
|
||||
}
|
||||
6
test/fixtures/custom-source-with-cwd/package.json
vendored
Normal file
6
test/fixtures/custom-source-with-cwd/package.json
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "custom-source-with-cwd",
|
||||
"scripts": {
|
||||
"build": "microbundle --cwd ./custom-source"
|
||||
}
|
||||
}
|
||||
4
test/fixtures/custom-source/package.json
vendored
Normal file
4
test/fixtures/custom-source/package.json
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "custom-source",
|
||||
"source": "src/custom-source.js"
|
||||
}
|
||||
5
test/fixtures/custom-source/src/custom-source.js
vendored
Normal file
5
test/fixtures/custom-source/src/custom-source.js
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
import { two } from './two';
|
||||
|
||||
export default async function(...args) {
|
||||
return [await two(...args), await two(...args)];
|
||||
}
|
||||
3
test/fixtures/custom-source/src/two.js
vendored
Normal file
3
test/fixtures/custom-source/src/two.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
export async function two(...args) {
|
||||
return args.reduce((total, value) => total + value, 0);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user