Skip to content

Commit

Permalink
fix: correct import_map attribute name in validation (netlify/edge-bu…
Browse files Browse the repository at this point in the history
…ndler#241)

* fix: use correct import_map key for validation

* chore: add test to catch this in the future

* fix: remove unneded type specifier

* fix: imports have to end on .js

* fix: update snapshot
  • Loading branch information
Skn0tt committed Dec 6, 2022
1 parent 2768b0e commit 082c014
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions packages/edge-bundler/node/bundler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { useFixture } from '../test/util.js'
import { BundleError } from './bundle_error.js'
import { bundle, BundleOptions } from './bundler.js'
import { isNodeError } from './utils/error.js'
import { validateManifest } from './validation/manifest/index.js'

test('Produces an ESZIP bundle', async () => {
const { basePath, cleanup, distPath } = await useFixture('with_import_maps')
Expand All @@ -34,6 +35,7 @@ test('Produces an ESZIP bundle', async () => {

const manifestFile = await fs.readFile(resolve(distPath, 'manifest.json'), 'utf8')
const manifest = JSON.parse(manifestFile)
expect(() => validateManifest(manifest)).not.toThrowError()
const { bundles, import_map: importMapURL } = manifest

expect(bundles.length).toBe(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ TYPE must be string
28 | ],
29 | \\"bundler_version\\": \\"1.6.0\\",
> 30 | \\"importMapURL\\": [
| ^
> 30 | \\"import_map\\": [
| ^
> 31 | \\"file:///root/.netlify/edge-functions-dist/import_map.json\\"
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 32 | ]
Expand Down
4 changes: 2 additions & 2 deletions packages/edge-bundler/node/validation/manifest/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,14 @@ describe('layers', () => {
describe('import map URL', () => {
test('should accept string value', () => {
const manifest = getBaseManifest()
manifest.importMapURL = 'file:///root/.netlify/edge-functions-dist/import_map.json'
manifest.import_map = 'file:///root/.netlify/edge-functions-dist/import_map.json'

expect(() => validateManifest(manifest)).not.toThrowError()
})

test('should throw on wrong type', () => {
const manifest = getBaseManifest()
manifest.importMapURL = ['file:///root/.netlify/edge-functions-dist/import_map.json']
manifest.import_map = ['file:///root/.netlify/edge-functions-dist/import_map.json']

expect(() => validateManifest(manifest)).toThrowErrorMatchingSnapshot()
})
Expand Down
2 changes: 1 addition & 1 deletion packages/edge-bundler/node/validation/manifest/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const edgeManifestSchema = {
type: 'array',
items: layersSchema,
},
importMapURL: { type: 'string' },
import_map: { type: 'string' },
bundler_version: { type: 'string' },
},
additionalProperties: false,
Expand Down

0 comments on commit 082c014

Please sign in to comment.