-
Notifications
You must be signed in to change notification settings - Fork 522
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(esbuild): 'output' is passed twice when used (#2587)
Fix esbuild_macro always passing the 'output' argument as generated by the rule's name even when the user provides their own 'output' argument.
- Loading branch information
1 parent
425dbd6
commit 57218a6
Showing
4 changed files
with
69 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
load("//packages/esbuild/test:tests.bzl", "esbuild") | ||
load("//packages/jasmine:index.bzl", "jasmine_node_test") | ||
load("//packages/typescript:index.bzl", "ts_library") | ||
|
||
ts_library( | ||
name = "main", | ||
srcs = [ | ||
"main.ts", | ||
], | ||
deps = [ | ||
"@npm//@types/node", | ||
], | ||
) | ||
|
||
esbuild( | ||
name = "bundle_different_output", | ||
args = ["--keep-names"], | ||
entry_point = "main.ts", | ||
output = "different_output.js", | ||
deps = [":main"], | ||
) | ||
|
||
jasmine_node_test( | ||
name = "bundle_test", | ||
srcs = ["bundle_test.js"], | ||
data = [ | ||
":bundle_different_output", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const {readFileSync} = require('fs'); | ||
const path = require('path'); | ||
|
||
const helper = require(process.env.BAZEL_NODE_RUNFILES_HELPER); | ||
const locationBase = 'build_bazel_rules_nodejs/packages/esbuild/test/output/'; | ||
|
||
// Location for :bundle_output | ||
const bundleOutputLocation = helper.resolve(path.join(locationBase, 'different_output.js')); | ||
const bundleOutputSourcemapLocation = | ||
helper.resolve(path.join(locationBase, 'different_output.js.map')); | ||
|
||
describe('esbuild sourcemap', () => { | ||
it('writes the bundle with name specified by \'output\'', () => { | ||
const bundle = readFileSync(bundleOutputLocation, {encoding: 'utf8'}); | ||
expect(bundle).toContain('foo = {'); | ||
// Sourcemaps should point to the right file | ||
expect(bundle).toContain('//# sourceMappingURL=different_output.js.map'); | ||
}); | ||
|
||
it('writes the sourcemap with name specified by \'output\'', () => { | ||
const sourcemap = readFileSync(bundleOutputSourcemapLocation, {encoding: 'utf8'}); | ||
expect(sourcemap).toContain('"sources":'); | ||
expect(sourcemap).toContain('"mappings":'); | ||
}); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export interface Foo { | ||
x: number, y: string, | ||
} | ||
|
||
export const foo: Foo = { | ||
x: 123, | ||
y: 'hello', | ||
} |