Skip to content

Commit

Permalink
follow-up for #440/#441
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Oct 8, 2020
1 parent 2cb5f40 commit d906d5f
Show file tree
Hide file tree
Showing 2 changed files with 23 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 `mainFields` in the JavaScript API ([#440](https://github.com/evanw/esbuild/issues/440) and [#441](https://github.com/evanw/esbuild/pull/441))

It turns out the JavaScript bindings for the `mainFields` API option didn't work due to a copy/paste error. The fix for this was contributed by [@yoyo930021](https://github.com/yoyo930021).

## 0.7.12

* Fix another subtle ordering issue with `import` statements
Expand Down
17 changes: 17 additions & 0 deletions scripts/js-api-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,23 @@ let buildTests = {
assert.strictEqual(require(output).result, 123)
},

async mainFields({ esbuild, testDir }) {
const input = path.join(testDir, 'in.js')
const output = path.join(testDir, 'out.js')
const mainFieldsDir = path.join(testDir, 'node_modules', 'main-fields-test')
const mainFieldsA = path.join(mainFieldsDir, 'a.js')
const mainFieldsB = path.join(mainFieldsDir, 'b.js')
const mainFieldsPackage = path.join(mainFieldsDir, 'package.json')
await mkdirAsync(mainFieldsDir, { recursive: true })
await writeFileAsync(input, 'export * from "main-fields-test"')
await writeFileAsync(mainFieldsA, 'export let foo = "a"')
await writeFileAsync(mainFieldsB, 'export let foo = "b"')
await writeFileAsync(mainFieldsPackage, '{ "a": "./a.js", "b": "./b.js", "c": "./c.js" }')
await esbuild.build({ entryPoints: [input], outfile: output, bundle: true, format: 'cjs', mainFields: ['c', 'b', 'a'] })
const result = require(output)
assert.strictEqual(result.foo, 'b')
},

async requireAbsolutePath({ esbuild, testDir }) {
const input = path.join(testDir, 'in.js')
const dependency = path.join(testDir, 'dep.js')
Expand Down

0 comments on commit d906d5f

Please sign in to comment.