Skip to content

Commit 962297f

Browse files
committed
Updates edge bundling to use --node-modules-dir=false flag
Adds the `--node-modules-dir=false` flag to deno bundle commands in both tarball and eszip bundling formats. This ensures consistent handling of node modules during edge function bundling and updates related tests to reflect the new flag usage. The change improves reliability of the bundling process by explicitly disabling node modules directory handling.
1 parent 4f7e46f commit 962297f

File tree

7 files changed

+16
-72
lines changed

7 files changed

+16
-72
lines changed

packages/build/tests/edge_functions/snapshots/tests.js.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,7 +1279,7 @@ Generated by [AVA](https://avajs.dev).
12791279
────────────────────────────────────────────────────────────────␊
12801280
12811281
Error message␊
1282-
Error: Command failed with exit code 1: deno bundle --import-map BASE64_STRING --quiet --code-splitting --allow-import --outdir /external/path packages/build/tests/edge_functions/fixtures/functions_invalid/netlify/edge-functions/functions-1.ts␊
1282+
Error: Command failed with exit code 1: deno bundle --import-map BASE64_STRING --quiet --code-splitting --allow-import --node-modules-dir=manual --outdir /external/path packages/build/tests/edge_functions/fixtures/functions_invalid/netlify/edge-functions/functions-1.ts␊
12831283
STACK TRACE␊
12841284
12851285
export async () => ␊
@@ -1292,9 +1292,9 @@ Generated by [AVA](https://avajs.dev).
12921292
12931293
Error properties␊
12941294
{␊
1295-
shortMessage: 'Command failed with exit code 1: deno bundle --import-map BASE64_STRING --quiet --code-splitting --allow-import --outdir /external/path packages/build/tests/edge_functions/fixtures/functions_invalid/netlify/edge-functions/functions-1.ts',␊
1296-
command: 'deno bundle --import-map BASE64_STRING --quiet --code-splitting --allow-import --outdir /external/path packages/build/tests/edge_functions/fixtures/functions_invalid/netlify/edge-functions/functions-1.ts',␊
1297-
escapedCommand: 'deno bundle --import-map "BASE64_STRING" --quiet --code-splitting --allow-import --outdir "/external/path" "packages/build/tests/edge_functions/fixtures/functions_invalid/netlify/edge-functions/functions-1.ts"',␊
1295+
shortMessage: 'Command failed with exit code 1: deno bundle --import-map BASE64_STRING --quiet --code-splitting --allow-import --node-modules-dir=manual --outdir /external/path packages/build/tests/edge_functions/fixtures/functions_invalid/netlify/edge-functions/functions-1.ts',␊
1296+
command: 'deno bundle --import-map BASE64_STRING --quiet --code-splitting --allow-import --node-modules-dir=manual --outdir /external/path packages/build/tests/edge_functions/fixtures/functions_invalid/netlify/edge-functions/functions-1.ts',␊
1297+
escapedCommand: 'deno bundle --import-map "BASE64_STRING" --quiet --code-splitting --allow-import "--node-modules-dir=manual" --outdir "/external/path" "packages/build/tests/edge_functions/fixtures/functions_invalid/netlify/edge-functions/functions-1.ts"',␊
12981298
exitCode: 1,␊
12991299
signal: undefined,␊
13001300
signalDescription: undefined,␊
23 Bytes
Binary file not shown.

packages/build/tests/install/snapshots/tests.js.md

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,70 +1159,3 @@ Generated by [AVA](https://avajs.dev).
11591159
11601160
(Netlify Build completed in 1ms)␊
11611161
Build step duration: Netlify Build completed in 1ms`
1162-
1163-
## In integration dev mode, install local plugins and install the integration when forcing build
1164-
1165-
> Snapshot 1
1166-
1167-
`␊
1168-
Netlify Build ␊
1169-
────────────────────────────────────────────────────────────────␊
1170-
1171-
> Version␊
1172-
@netlify/build 1.0.0␊
1173-
1174-
> Flags␊
1175-
context: dev␊
1176-
debug: true␊
1177-
repositoryRoot: packages/build/tests/install/fixtures/local_missing_integration␊
1178-
testOpts:␊
1179-
pluginsListUrl: test␊
1180-
silentLingeringProcesses: true␊
1181-
1182-
> Current directory␊
1183-
packages/build/tests/install/fixtures/local_missing_integration␊
1184-
1185-
> Config file␊
1186-
packages/build/tests/install/fixtures/local_missing_integration/netlify.toml␊
1187-
1188-
> Resolved config␊
1189-
build:␊
1190-
publish: packages/build/tests/install/fixtures/local_missing_integration␊
1191-
publishOrigin: default␊
1192-
1193-
> Context␊
1194-
dev␊
1195-
1196-
> Installing extensions␊
1197-
- functions-injection␊
1198-
1199-
> Loading extensions␊
1200-
- functions-injection␊
1201-
1202-
functions-injection-buildhooks (onPreBuild event) ␊
1203-
────────────────────────────────────────────────────────────────␊
1204-
1205-
Hello from onPreBuild␊
1206-
1207-
(functions-injection-buildhooks onPreBuild completed in 1ms)␊
1208-
Build step duration: functions-injection-buildhooks onPreBuild completed in 1ms␊
1209-
1210-
Functions bundling ␊
1211-
────────────────────────────────────────────────────────────────␊
1212-
1213-
Packaging Functions generated by functions-injection extension:␊
1214-
- my_unique_prefix_2_function-with-external-dependencies-directory␊
1215-
- my_unique_prefix_2_function-with-external-dependencies-directory-multifile␊
1216-
- my_unique_prefix_2_function-with-external-dependencies.ts␊
1217-
- my_unique_prefix_2_function-with-local-dependencies.ts␊
1218-
- my_unique_prefix_2_function-with-no-dependencies.ts␊
1219-
1220-
1221-
(Functions bundling completed in 1ms)␊
1222-
Build step duration: Functions bundling completed in 1ms␊
1223-
1224-
Netlify Build Complete ␊
1225-
────────────────────────────────────────────────────────────────␊
1226-
1227-
(Netlify Build completed in 1ms)␊
1228-
Build step duration: Netlify Build completed in 1ms`
-77 Bytes
Binary file not shown.

packages/edge-bundler/node/bundler.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,16 @@ describe.skipIf(lt(denoVersion, '2.4.3'))(
845845
const tarballResult = await runTarball(tarballPath)
846846
expect(tarballResult.func1).toBe(expectedOutput)
847847

848+
const tarballExtraction = await tmp.dir({ unsafeCleanup: true })
849+
await tar.extract({
850+
cwd: tarballExtraction.path,
851+
file: tarballPath,
852+
})
853+
const denoConfigPath = join(tarballExtraction.path, 'deno.json')
854+
const denoConfig = JSON.parse(await readFile(denoConfigPath, 'utf8'))
855+
expect(denoConfig.imports).toHaveProperty('parent-1')
856+
await tarballExtraction.cleanup()
857+
848858
const eszipPath = join(distPath, manifest.bundles[1].asset)
849859
const eszipResult = await runESZIP(eszipPath, vendorDirectory.path)
850860
expect(eszipResult.func1).toBe(expectedOutput)

packages/edge-bundler/node/formats/eszip.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export const bundle = async ({
5858
importMapData,
5959
vendorDirectory,
6060
}
61-
const flags = ['--allow-all', '--no-config', `--import-map=${bundlerImportMap}`]
61+
const flags = ['--allow-all', '--no-config', '--node-modules-dir=false', `--import-map=${bundlerImportMap}`]
6262

6363
if (!debug) {
6464
flags.push('--quiet')

packages/edge-bundler/node/formats/tarball.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ export const bundle = async ({
8888
'--quiet',
8989
'--code-splitting',
9090
'--allow-import',
91+
'--node-modules-dir=false',
9192
'--outdir',
9293
bundleDir.path,
9394
...functions.map((func) => func.path),

0 commit comments

Comments
 (0)