Skip to content
Prev Previous commit
Next Next commit
fix: try scoping down the import map
  • Loading branch information
Skn0tt committed Sep 29, 2023
commit 30416b5ec4d08783b358a5966196096c0a2c2c56
18 changes: 18 additions & 0 deletions packages/runtime/fix-import-map.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const fs = require('fs')
const path = require('path')

const importMapPath = path.join('.', 'src', 'templates', 'vendor', 'import_map.json')

// eslint-disable-next-line n/no-sync
const contents = JSON.parse(fs.readFileSync(importMapPath))

const scopedImportMap = {
// this empty object is required, so that edge-bundler doesn't fail :/
imports: {},
scopes: {
'file:///root/.netlify/edge-functions/': contents.imports,
},
}

// eslint-disable-next-line n/no-sync
fs.writeFileSync(importMapPath, JSON.stringify(scopedImportMap, null, 2))
2 changes: 1 addition & 1 deletion packages/runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"publish:test": "cd .. && npm ci && npm test",
"clean": "rimraf lib dist-types",
"build": "run-s build:*",
"build:vendor": "rimraf src/templates/vendor && deno vendor src/templates/edge/shims.js src/templates/edge-shared/next-utils.ts https://deno.land/x/html_rewriter@v0.1.0-pre.17/index.ts --output=src/templates/vendor",
"build:vendor": "rimraf src/templates/vendor && deno vendor src/templates/edge/shims.js src/templates/edge-shared/next-utils.ts https://deno.land/x/html_rewriter@v0.1.0-pre.17/index.ts --output=src/templates/vendor && node fix-import-map.js",
"build:tsc": "tsc",
"watch": "tsc --watch",
"prepare": "npm run build"
Expand Down