Skip to content

Commit

Permalink
fix: remap netlify:edge specifier (#467)
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoboucas authored Sep 6, 2023
1 parent 7176a22 commit 9728d1a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions node/import_map.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ test('Handles import maps with full URLs without specifying a base URL', () => {
const map = new ImportMap([inputFile1, inputFile2])
const { imports } = map.getContents()

expect(imports['netlify:edge']).toBe('https://edge.netlify.com/v1/index.ts')
expect(imports['netlify:edge']).toBe('https://edge.netlify.com/v1/index.ts?v=legacy')
expect(imports['@netlify/edge-functions']).toBe('https://edge.netlify.com/v1/index.ts')
expect(imports['alias:jamstack']).toBe('https://jamstack.org/')
expect(imports['alias:pets']).toBe('https://petsofnetlify.com/')
})
Expand All @@ -44,7 +45,8 @@ test('Resolves relative paths to absolute paths if a base path is not provided',
const { imports } = map.getContents()
const expectedPath = join(cwd(), 'my-cool-site', 'heart', 'pets')

expect(imports['netlify:edge']).toBe('https://edge.netlify.com/v1/index.ts')
expect(imports['netlify:edge']).toBe('https://edge.netlify.com/v1/index.ts?v=legacy')
expect(imports['@netlify/edge-functions']).toBe('https://edge.netlify.com/v1/index.ts')
expect(imports['alias:pets']).toBe(`${pathToFileURL(expectedPath).toString()}/`)
})

Expand Down Expand Up @@ -81,7 +83,7 @@ describe('Returns the fully resolved import map', () => {
specifier2: 'file:///some/full/path/file2.js',
specifier1: 'file:///some/full/path/file.js',
'@netlify/edge-functions': 'https://edge.netlify.com/v1/index.ts',
'netlify:edge': 'https://edge.netlify.com/v1/index.ts',
'netlify:edge': 'https://edge.netlify.com/v1/index.ts?v=legacy',
})

expect(scopes).toStrictEqual({
Expand All @@ -106,7 +108,7 @@ describe('Returns the fully resolved import map', () => {
specifier2: 'file:///root/full/path/file2.js',
specifier1: 'file:///root/full/path/file.js',
'@netlify/edge-functions': 'https://edge.netlify.com/v1/index.ts',
'netlify:edge': 'https://edge.netlify.com/v1/index.ts',
'netlify:edge': 'https://edge.netlify.com/v1/index.ts?v=legacy',
})

expect(scopes).toStrictEqual({
Expand Down Expand Up @@ -154,6 +156,7 @@ test('Writes import map file to disk', async () => {

await file.cleanup()

expect(imports['netlify:edge']).toBe('https://edge.netlify.com/v1/index.ts')
expect(imports['netlify:edge']).toBe('https://edge.netlify.com/v1/index.ts?v=legacy')
expect(imports['@netlify/edge-functions']).toBe('https://edge.netlify.com/v1/index.ts')
expect(imports['alias:pets']).toBe(pathToFileURL(expectedPath).toString())
})
2 changes: 1 addition & 1 deletion node/import_map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { isFileNotFoundError } from './utils/error.js'

const INTERNAL_IMPORTS = {
'@netlify/edge-functions': 'https://edge.netlify.com/v1/index.ts',
'netlify:edge': 'https://edge.netlify.com/v1/index.ts',
'netlify:edge': 'https://edge.netlify.com/v1/index.ts?v=legacy',
}

type Imports = Record<string, string>
Expand Down

0 comments on commit 9728d1a

Please sign in to comment.