Skip to content

Commit

Permalink
fix(options): bundle defaults
Browse files Browse the repository at this point in the history
Signed-off-by: Lexus Drumgold <[email protected]>
  • Loading branch information
unicornware committed Feb 16, 2023
1 parent c09abaa commit 51c88a9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 22 deletions.
36 changes: 21 additions & 15 deletions src/internal/esbuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,27 @@ const esbuilder = async (
*
* @const {string[]} files
*/
const files: string[] = await fg(bundle ? source : pattern, {
braceExpansion: true,
caseSensitiveMatch: true,
cwd: pathe.join(absWorkingDir, bundle ? '' : source),
dot: true,
extglob: true,
fs: omit(fs, ['readdir']),
globstar: true,
ignore: [...new Set(ignore)],
objectMode: false,
onlyFiles: true,
stats: false,
throwErrorOnBrokenSymbolicLink: false,
unique: true
})
const files: string[] = await fg(
bundle
? (!pathe.extname(source) && source + '.*') || /* c8 ignore next */ source
: pattern,
{
absolute: false,
braceExpansion: true,
caseSensitiveMatch: true,
cwd: pathe.join(absWorkingDir, bundle ? '' : source),
dot: true,
extglob: true,
fs: omit(fs, ['readdir']),
globstar: true,
ignore: [...new Set(ignore)],
objectMode: false,
onlyFiles: true,
stats: false,
throwErrorOnBrokenSymbolicLink: false,
unique: true
}
)

/**
* Source file objects.
Expand Down
13 changes: 6 additions & 7 deletions src/make.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ async function make({ cwd = '.', ...config }: Config = {}): Promise<Result[]> {
} = defu(await loadBuildConfig(cwd), config, {
bundle: false,
clean: true,
createRequire: false,
cwd,
dts: await (async () => {
try {
Expand All @@ -66,7 +65,6 @@ async function make({ cwd = '.', ...config }: Config = {}): Promise<Result[]> {
ignore: [...IGNORE_PATTERNS],
outdir: 'dist',
pattern: '**',
platform: '',
source: 'src',
write: false
})
Expand Down Expand Up @@ -99,17 +97,18 @@ async function make({ cwd = '.', ...config }: Config = {}): Promise<Result[]> {
bundle = options.bundle,
cwd: entrydir = cwd,
format = options.format,
platform = options.platform
platform,
source = options.source
} = entry

// remove default source to reset based on bundling
Reflect.deleteProperty(options, 'source')

return defuConcat(entry, options, {
bundle,
createRequire: bundle && format === 'esm' && platform === 'node',
cwd: pathe.resolve(cwd, entrydir),
external: bundle ? Object.keys(peerDependencies) : [],
format,
platform,
source: bundle ? 'src/index' : options.source
source: (!bundle && source) || source || /* c8 ignore next */ 'src/index'
})
})

Expand Down

0 comments on commit 51c88a9

Please sign in to comment.