Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def __init__(self, source_dir, artifacts_dir, scratch_dir, manifest_path, runtim
subprocess_npm=self.subprocess_npm,
osutils=self.osutils,
build_options=self.options,
install_links=self.build_dir == self.source_dir,
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,3 +463,31 @@ def test_esbuild_can_build_in_source(self, runtime):
expected_files = {"included.js"}
output_files = set(os.listdir(self.artifacts_dir))
self.assertEqual(expected_files, output_files)

@parameterized.expand([("nodejs12.x",), ("nodejs14.x",), ("nodejs16.x",), ("nodejs18.x",)])
def test_esbuild_can_build_in_source_with_local_dependency(self, runtime):
self.source_dir = os.path.join(self.TEST_DATA_FOLDER, "with-local-dependency")

options = {"entry_points": ["included.js"]}

self.builder.build(
self.source_dir,
self.artifacts_dir,
self.scratch_dir,
os.path.join(self.source_dir, "package.json"),
runtime=runtime,
options=options,
executable_search_paths=[self.binpath],
build_in_source=True,
)

# dependencies installed in source folder
self.assertIn("node_modules", os.listdir(self.source_dir))

# dependencies not in scratch
self.assertNotIn("node_modules", os.listdir(self.scratch_dir))

# bundle is in artifacts
expected_files = {"included.js"}
output_files = set(os.listdir(self.artifacts_dir))
self.assertEqual(expected_files, output_files)
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"keywords": [],
"author": "",
"license": "APACHE2.0",
"main": "included.js",
"devDependencies": {
"esbuild": "^0.14.36"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
//excluded
const x = 1;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//included
const localdep = require('local-dependency');
exports.handler = async (event, context) => {
return localdep;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "with-local-dependency",
"version": "1.0.0",
"description": "",
"keywords": [],
"author": "",
"license": "APACHE2.0",
"main": "included.js",
"dependencies": {
"local-dependency": "file:../no-deps-esbuild"
},
"devDependencies": {
"esbuild": "^0.11.23"
}
}
7 changes: 6 additions & 1 deletion tests/unit/workflows/nodejs_npm_esbuild/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,12 @@ def test_workflow_uses_production_npm_version(self, get_workflow_mock):
self.assertIsInstance(workflow.actions[2], EsbuildBundleAction)

get_workflow_mock.get_install_action.assert_called_with(
source_dir="source", install_dir="scratch_dir", subprocess_npm=ANY, osutils=ANY, build_options=None
source_dir="source",
install_dir="scratch_dir",
subprocess_npm=ANY,
osutils=ANY,
build_options=None,
install_links=False,
)

@patch("aws_lambda_builders.workflows.nodejs_npm_esbuild.workflow.NodejsNpmEsbuildWorkflow._get_esbuild_subprocess")
Expand Down