Skip to content

Commit 30416b5

Browse files
committed
fix: try scoping down the import map
1 parent 88ac9a9 commit 30416b5

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

packages/runtime/fix-import-map.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const fs = require('fs')
2+
const path = require('path')
3+
4+
const importMapPath = path.join('.', 'src', 'templates', 'vendor', 'import_map.json')
5+
6+
// eslint-disable-next-line n/no-sync
7+
const contents = JSON.parse(fs.readFileSync(importMapPath))
8+
9+
const scopedImportMap = {
10+
// this empty object is required, so that edge-bundler doesn't fail :/
11+
imports: {},
12+
scopes: {
13+
'file:///root/.netlify/edge-functions/': contents.imports,
14+
},
15+
}
16+
17+
// eslint-disable-next-line n/no-sync
18+
fs.writeFileSync(importMapPath, JSON.stringify(scopedImportMap, null, 2))

packages/runtime/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"publish:test": "cd .. && npm ci && npm test",
5454
"clean": "rimraf lib dist-types",
5555
"build": "run-s build:*",
56-
"build:vendor": "rimraf src/templates/vendor && deno vendor src/templates/edge/shims.js src/templates/edge-shared/next-utils.ts https://deno.land/x/[email protected]/index.ts --output=src/templates/vendor",
56+
"build:vendor": "rimraf src/templates/vendor && deno vendor src/templates/edge/shims.js src/templates/edge-shared/next-utils.ts https://deno.land/x/[email protected]/index.ts --output=src/templates/vendor && node fix-import-map.js",
5757
"build:tsc": "tsc",
5858
"watch": "tsc --watch",
5959
"prepare": "npm run build"

0 commit comments

Comments
 (0)