Skip to content

Commit

Permalink
fix omission of "outbase" in js api (#471)
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Nov 1, 2020
1 parent 5f21bad commit 05e64d6
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

* Fix the omission of `outbase` in the JavaScript API ([#471](https://github.com/evanw/esbuild/pull/471))

The original PR for the `outbase` setting added it to the CLI and Go APIs but not the JavaScript API. This release adds it to the JavaScript API too.

## 0.8.1

* The initial version of the plugin API ([#111](https://github.com/evanw/esbuild/pull/111))
Expand Down
2 changes: 2 additions & 0 deletions lib/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ function flagsForBuildOptions(options: types.BuildOptions, isTTY: boolean, logLe
let metafile = getFlag(options, keys, 'metafile', mustBeString);
let outfile = getFlag(options, keys, 'outfile', mustBeString);
let outdir = getFlag(options, keys, 'outdir', mustBeString);
let outbase = getFlag(options, keys, 'outbase', mustBeString);
let platform = getFlag(options, keys, 'platform', mustBeString);
let tsconfig = getFlag(options, keys, 'tsconfig', mustBeString);
let resolveExtensions = getFlag(options, keys, 'resolveExtensions', mustBeArray);
Expand All @@ -150,6 +151,7 @@ function flagsForBuildOptions(options: types.BuildOptions, isTTY: boolean, logLe
if (metafile) flags.push(`--metafile=${metafile}`);
if (outfile) flags.push(`--outfile=${outfile}`);
if (outdir) flags.push(`--outdir=${outdir}`);
if (outbase) flags.push(`--outbase=${outbase}`);
if (platform) flags.push(`--platform=${platform}`);
if (tsconfig) flags.push(`--tsconfig=${tsconfig}`);
if (resolveExtensions) flags.push(`--resolve-extensions=${resolveExtensions.join(',')}`);
Expand Down
1 change: 1 addition & 0 deletions lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export interface BuildOptions extends CommonOptions {
outfile?: string;
metafile?: string;
outdir?: string;
outbase?: string;
platform?: Platform;
color?: boolean;
external?: string[];
Expand Down
16 changes: 16 additions & 0 deletions scripts/js-api-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,22 @@ console.log("success");
assert.strictEqual(contents.indexOf('=>'), -1)
assert.strictEqual(contents.indexOf('const'), -1)
},

async outbase({ esbuild, testDir }) {
const outbase = path.join(testDir, 'pages')
const b = path.join(outbase, 'a', 'b', 'index.js')
const c = path.join(outbase, 'a', 'c', 'index.js')
const outdir = path.join(testDir, 'outdir')
await mkdirAsync(path.dirname(b), { recursive: true })
await mkdirAsync(path.dirname(c), { recursive: true })
await writeFileAsync(b, 'module.exports = "b"')
await writeFileAsync(c, 'module.exports = "c"')
await esbuild.build({ entryPoints: [b, c], outdir, outbase, format: 'cjs' })
const outB = path.join(outdir, path.relative(outbase, b))
const outC = path.join(outdir, path.relative(outbase, c))
assert.strictEqual(require(outB), 'b')
assert.strictEqual(require(outC), 'c')
},
}

async function futureSyntax(service, js, targetBelow, targetAbove) {
Expand Down

0 comments on commit 05e64d6

Please sign in to comment.