-
Notifications
You must be signed in to change notification settings - Fork 524
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(esbuild): add support for plugins via supplying a configuration …
…file (#2840)
- Loading branch information
Showing
16 changed files
with
427 additions
and
21 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
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,27 @@ | ||
"esbuild configuration file helper macro" | ||
|
||
load("@build_bazel_rules_nodejs//:index.bzl", _js_library = "js_library") | ||
|
||
def esbuild_config(name, config_file, srcs = [], deps = [], **kwargs): | ||
"""Macro for an esbuild configuration file and its assoicated dependencies | ||
Args: | ||
name: Unique name for this rule | ||
config_file: The configuration file / entrypoint | ||
srcs: List of source files referenced by the configuration | ||
deps: List of dependencies required for this configuration | ||
**kwargs: Any other common attributes | ||
""" | ||
|
||
_js_library( | ||
name = name, | ||
srcs = [config_file], | ||
**kwargs | ||
) | ||
|
||
_js_library( | ||
name = "%s_deps" % name, | ||
srcs = srcs, | ||
deps = deps, | ||
**kwargs | ||
) |
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
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,57 @@ | ||
load("//:index.bzl", "generated_file_test", "js_library", "nodejs_binary", "npm_package_bin") | ||
load("//packages/esbuild:index.bzl", "esbuild") | ||
load("//packages/esbuild:esbuild_config.bzl", "esbuild_config") | ||
|
||
js_library( | ||
name = "main", | ||
srcs = [ | ||
"logo.svg", | ||
"main.js", | ||
"words.txt", | ||
], | ||
) | ||
|
||
js_library( | ||
name = "txt_array_plugin", | ||
srcs = [ | ||
"txt-array-plugin.js", | ||
], | ||
) | ||
|
||
esbuild_config( | ||
name = "esbuild_config", | ||
config_file = "esbuild.config.mjs", | ||
deps = [ | ||
":txt_array_plugin", | ||
"@npm//esbuild-plugin-svg", | ||
], | ||
) | ||
|
||
esbuild( | ||
name = "bundle", | ||
config = ":esbuild_config", | ||
entry_point = "main.js", | ||
deps = [ | ||
":main", | ||
], | ||
) | ||
|
||
nodejs_binary( | ||
name = "bin", | ||
data = [ | ||
":bundle", | ||
], | ||
entry_point = "bundle.js", | ||
) | ||
|
||
npm_package_bin( | ||
name = "runner", | ||
stdout = "out.txt", | ||
tool = ":bin", | ||
) | ||
|
||
generated_file_test( | ||
name = "test", | ||
src = "out.golden.txt", | ||
generated = "out.txt", | ||
) |
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,9 @@ | ||
import { default as txtArrayPlugin } from './txt-array-plugin.js'; | ||
import { default as svgPlugin } from 'esbuild-plugin-svg'; | ||
|
||
export default { | ||
plugins: [ | ||
txtArrayPlugin, | ||
svgPlugin(), | ||
], | ||
} |
Oops, something went wrong.