File tree Expand file tree Collapse file tree 4 files changed +41
-1
lines changed
Expand file tree Collapse file tree 4 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ def _esbuild_impl(ctx):
4949 args .add_joined (["--target" , ctx .attr .target ], join_with = "=" )
5050 args .add_joined (["--log-level" , "info" ], join_with = "=" )
5151 args .add_joined (["--metafile" , metafile .path ], join_with = "=" )
52- args .add_all (ctx .attr .define , format_each = "--define= %s" )
52+ args .add_all (ctx .attr .define , format_each = "--define: %s" )
5353 args .add_all (ctx .attr .external , format_each = "--external=%s" )
5454
5555 # disable the error limit and show all errors
Original file line number Diff line number Diff line change 1+ load ("//packages/esbuild/test:tests.bzl" , "esbuild" )
2+ load ("//packages/jasmine:index.bzl" , "jasmine_node_test" )
3+ load ("//packages/typescript:index.bzl" , "ts_library" )
4+
5+ ts_library (
6+ name = "main" ,
7+ srcs = [
8+ "main.ts" ,
9+ ],
10+ deps = [
11+ "@npm//@types/node" ,
12+ ],
13+ )
14+
15+ esbuild (
16+ name = "bundle" ,
17+ define = [
18+ "process.env.NODE_ENV=\" defined_in_bundle\" " ,
19+ ],
20+ entry_point = "main.ts" ,
21+ deps = [":main" ],
22+ )
23+
24+ jasmine_node_test (
25+ name = "bundle_test" ,
26+ srcs = ["bundle_test.js" ],
27+ data = [":bundle" ],
28+ )
Original file line number Diff line number Diff line change 1+ const { readFileSync} = require ( 'fs' ) ;
2+
3+ const helper = require ( process . env . BAZEL_NODE_RUNFILES_HELPER ) ;
4+ const location = helper . resolve ( 'build_bazel_rules_nodejs/packages/esbuild/test/define/bundle.js' ) ;
5+
6+ describe ( 'esbuild define' , ( ) => {
7+ it ( 'defines variables' , ( ) => {
8+ const bundle = readFileSync ( location , { encoding : 'utf8' } ) ;
9+ expect ( bundle ) . toContain ( `nodeEnv = "defined_in_bundle"` ) ;
10+ } ) ;
11+ } )
Original file line number Diff line number Diff line change 1+ export const nodeEnv = process . env . NODE_ENV ;
You can’t perform that action at this time.
0 commit comments