Skip to content

Commit

Permalink
build: minor build script improvements (#944)
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub authored Nov 13, 2024
1 parent 3b6c120 commit 63403c3
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions scripts/build-js.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ const {
} = argv

const formats = format.split(',')
const cwd = Array.isArray(_cwd) ? _cwd[_cwd.length - 1] : _cwd
const cwd = [_cwd].flat().pop()
const entries = entry.split(/:\s?/)
const entryPoints = entry.includes('*')
? await glob(entries, { absolute: false, onlyFiles: true, cwd, root: cwd })
: entries.map((p) => path.relative(cwd, path.resolve(cwd, p)))

const _bundle = bundle !== 'none' && !process.argv.includes('--no-bundle')
const _bundle = bundle && bundle !== 'none'
const _external = _bundle ? external.split(',') : undefined // https://github.com/evanw/esbuild/issues/1466

const plugins = [
Expand Down Expand Up @@ -159,10 +159,16 @@ plugins.push(

function entryPointsToRegexp(entryPoints) {
return new RegExp(
'(' + entryPoints.map((e) => path.parse(e).name).join('|') + ')\\.cjs$'
'(' +
entryPoints.map((e) => escapeRegExp(path.parse(e).name)).join('|') +
')\\.cjs$'
)
}

function escapeRegExp(str) {
return str.replace(/[/\-\\^$*+?.()|[\]{}]/g, '\\$&')
}

const esmConfig = {
absWorkingDir: cwd,
entryPoints,
Expand Down

0 comments on commit 63403c3

Please sign in to comment.