Skip to content

Commit 7d697ca

Browse files
mildanielcalavera
authored andcommitted
feat: Add sources content flag to supported esbuild options (aws#439)
1 parent def9544 commit 7d697ca

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

aws_lambda_builders/workflows/nodejs_npm_esbuild/esbuild.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ def run(self, args, cwd=None):
114114
"target",
115115
"format",
116116
"main_fields",
117+
"sources_content",
117118
]
118119

119120
# Multi-value types (--external:axios --external:aws-sdk)

tests/integration/workflows/nodejs_npm_esbuild/test_nodejs_npm_with_esbuild.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import json
12
import os
23
import shutil
34
import tempfile
@@ -414,6 +415,29 @@ def test_esbuild_produces_mjs_output_files(self, runtime):
414415
output_files = set(os.listdir(self.artifacts_dir))
415416
self.assertEqual(expected_files, output_files)
416417

418+
@parameterized.expand([("nodejs12.x",), ("nodejs14.x",), ("nodejs16.x",), ("nodejs18.x",)])
419+
def test_esbuild_produces_sourcemap_without_source_contents(self, runtime):
420+
source_dir = os.path.join(self.TEST_DATA_FOLDER, "with-deps-esbuild")
421+
options = {"entry_points": ["included.js"], "sourcemap": True, "sources_content": "false"}
422+
423+
self.builder.build(
424+
source_dir,
425+
self.artifacts_dir,
426+
self.scratch_dir,
427+
os.path.join(source_dir, "package.json"),
428+
runtime=runtime,
429+
options=options,
430+
experimental_flags=[],
431+
executable_search_paths=[self.binpath],
432+
)
433+
434+
expected_files = {"included.js", "included.js.map"}
435+
output_files = set(os.listdir(self.artifacts_dir))
436+
with open(Path(self.artifacts_dir, "included.js.map")) as f:
437+
sourcemap = json.load(f)
438+
self.assertNotIn("sourcesContent", sourcemap)
439+
self.assertEqual(expected_files, output_files)
440+
417441
@parameterized.expand([("nodejs12.x",), ("nodejs14.x",), ("nodejs16.x",), ("nodejs18.x",)])
418442
def test_esbuild_can_build_in_source(self, runtime):
419443
options = {"entry_points": ["included.js"]}

tests/unit/workflows/nodejs_npm_esbuild/test_esbuild.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ def test_builds_args_from_config(self, osutils_mock):
196196
bundler_config = {
197197
"minify": True,
198198
"sourcemap": False,
199+
"sources_content": "false",
199200
"format": "esm",
200201
"target": "node14",
201202
"loader": [".proto=text", ".json=js"],
@@ -216,6 +217,7 @@ def test_builds_args_from_config(self, osutils_mock):
216217
"--target=node14",
217218
"--format=esm",
218219
"--main-fields=module,main",
220+
"--sources-content=false",
219221
"--external:aws-sdk",
220222
"--external:axios",
221223
"--loader:.proto=text",

0 commit comments

Comments
 (0)