-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use import maps for internal Netlify identifier (#5)
* chore: doh * refactor: fix merge conflict * chore: remove workspace file
- Loading branch information
1 parent
d27184a
commit c5fa05e
Showing
3 changed files
with
69 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Buffer } from 'buffer' | ||
import { promises as fs } from 'fs' | ||
import { dirname } from 'path' | ||
|
||
const DEFAULT_IMPORTS = { | ||
'netlify:edge': 'https://dinosaurs:are-the-future!@edge-bootstrap.netlify.app/v1/index.ts', | ||
} | ||
|
||
class ImportMap { | ||
imports: Record<string, string> | ||
|
||
constructor() { | ||
this.imports = DEFAULT_IMPORTS | ||
} | ||
|
||
getContents() { | ||
const contents = { | ||
imports: this.imports, | ||
} | ||
|
||
return JSON.stringify(contents) | ||
} | ||
|
||
toDataURL() { | ||
const encodedImportMap = Buffer.from(this.getContents()).toString('base64') | ||
|
||
return `data:application/json;base64,${encodedImportMap}` | ||
} | ||
|
||
async writeToFile(path: string) { | ||
await fs.mkdir(dirname(path), { recursive: true }) | ||
|
||
const contents = this.getContents() | ||
|
||
await fs.writeFile(path, contents) | ||
} | ||
} | ||
|
||
export { ImportMap } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters