-
Notifications
You must be signed in to change notification settings - Fork 519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(esbuild): add support for multiple entry points #2663
Merged
mattem
merged 1 commit into
bazel-contrib:stable
from
jbedard:esbuild-multi-entry-point
May 10, 2021
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,36 @@ | ||
load("//:index.bzl", "nodejs_test") | ||
load("//packages/esbuild/test:tests.bzl", "esbuild") | ||
load("//packages/typescript:index.bzl", "ts_library") | ||
|
||
ts_library( | ||
name = "index", | ||
srcs = ["index.ts"], | ||
module_name = "lib", | ||
) | ||
|
||
ts_library( | ||
name = "lib", | ||
srcs = [ | ||
"a.ts", | ||
"b.ts", | ||
], | ||
deps = [":index"], | ||
) | ||
|
||
esbuild( | ||
name = "bundle", | ||
entry_points = [ | ||
"a.ts", | ||
"b.ts", | ||
], | ||
deps = [":lib"], | ||
) | ||
|
||
nodejs_test( | ||
name = "bundle_test", | ||
data = [ | ||
"bundle.spec.js", | ||
":bundle", | ||
], | ||
entry_point = ":bundle.spec.js", | ||
) |
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,3 @@ | ||
import {NAME} from 'lib'; | ||
|
||
console.log(`Hello ${NAME}`); |
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,3 @@ | ||
import {NAME} from 'lib'; | ||
|
||
console.log(`Hello ${NAME} from b.ts`); |
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 {join} = require('path'); | ||
const {readFileSync, lstatSync} = require('fs'); | ||
|
||
const helper = require(process.env.BAZEL_NODE_RUNFILES_HELPER); | ||
const location = helper.resolve('build_bazel_rules_nodejs/packages/esbuild/test/entries/bundle/'); | ||
|
||
const a = readFileSync(join(location, 'a.js'), {encoding: 'utf8'}); | ||
const b = readFileSync(join(location, 'b.js'), {encoding: 'utf8'}); | ||
const aHasImportOfChunk = a.match(/\/(chunk-[a-zA-Z0-9]+\.js)";/); | ||
const bHasImportOfChunk = b.match(/\/(chunk-[a-zA-Z0-9]+\.js)";/); | ||
|
||
if (!aHasImportOfChunk || !bHasImportOfChunk) { | ||
console.error(`Expected entry_points 'a.js' and 'b.js' to have an import of './chunk-[hash].js'`); | ||
} | ||
|
||
if (aHasImportOfChunk[1] !== bHasImportOfChunk[1]) { | ||
console.error(`Expected entry_points 'a.js' and 'b.js' to the same shared chunk`); | ||
} | ||
|
||
// throws if file does not exist | ||
lstatSync(join(location, aHasImportOfChunk && aHasImportOfChunk[1])); | ||
|
||
process.exit( | ||
(aHasImportOfChunk && bHasImportOfChunk && aHasImportOfChunk[1] === bHasImportOfChunk[1]) ? 0 : | ||
1); |
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 @@ | ||
export const NAME = 'bazel'; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will cause an error when
output_dir
isTrue
as it will passentry_points = False
, whereentry_points
is expecting a label list, but will get a boolean.Perhaps something like the following (
None
is falsy and the default onlabel_list
is an empty list)It can then be removed from the macro's signature