Skip to content

Commit 03a9924

Browse files
feat: add build.edge_functions_import_map config property (#4774)
* feat: add `functions.import_map` config property * refactor: rename property * refactor: update validation example
1 parent 39ab35d commit 03a9924

File tree

5 files changed

+36
-0
lines changed

5 files changed

+36
-0
lines changed

packages/config/src/validate/validations.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,14 @@ export const POST_NORMALIZE_VALIDATIONS = [
187187
message: 'must be a string.',
188188
example: () => ({ build: { edge_functions: 'edge-functions' } }),
189189
},
190+
{
191+
property: 'build.edge_functions_import_map',
192+
check: isString,
193+
message: 'must be a string.',
194+
example: () => ({
195+
build: { edge_functions_import_map: 'path/to/import_map.json' },
196+
}),
197+
},
190198
{
191199
property: 'functions.*',
192200
check: isPlainObj,
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[build]
2+
edge_functions_import_map = ["not", "a", "string"]

packages/config/tests/validate/snapshots/tests.js.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,27 @@ Generated by [AVA](https://avajs.dev).
476476
`When resolving config file packages/config/tests/validate/fixtures/build_edge_functions_parent/netlify.toml:␊
477477
Configuration property "build.edge_functions" "edge_functions_dir" must be inside the repository root directory.`
478478

479+
## build.edge_functions_import_map: string
480+
481+
> Snapshot 1
482+
483+
`When resolving config file packages/config/tests/validate/fixtures/build_edge_functions_import_map/netlify.toml:␊
484+
Configuration property build.edge_functions_import_map must be a string.␊
485+
486+
Invalid syntax␊
487+
488+
[build]␊
489+
edge_functions_import_map = [␊
490+
"not",␊
491+
"a",␊
492+
"string"␊
493+
]␊
494+
495+
Valid syntax␊
496+
497+
[build]␊
498+
edge_functions_import_map = "path/to/import_map.json"`
499+
479500
## build.base: string
480501

481502
> Snapshot 1
71 Bytes
Binary file not shown.

packages/config/tests/validate/tests.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ test('build.edge_functions: parent directory', async (t) => {
113113
t.snapshot(normalizeOutput(output))
114114
})
115115

116+
test('build.edge_functions_import_map: string', async (t) => {
117+
const output = await new Fixture('./fixtures/build_edge_functions_import_map').runWithConfig()
118+
t.snapshot(normalizeOutput(output))
119+
})
120+
116121
test('build.base: string', async (t) => {
117122
const output = await new Fixture('./fixtures/build_base_string').runWithConfig()
118123
t.snapshot(normalizeOutput(output))

0 commit comments

Comments
 (0)