@netlify/edge-bundler 5.4.0 → 5.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3,7 +3,7 @@ import { join } from 'path';
|
|
|
3
3
|
import { env } from 'process';
|
|
4
4
|
import { pathToFileURL } from 'url';
|
|
5
5
|
import { deleteAsync } from 'del';
|
|
6
|
-
const BOOTSTRAP_LATEST = 'https://
|
|
6
|
+
const BOOTSTRAP_LATEST = 'https://639708f6d7f813000870695c--edge.netlify.com/bootstrap/index-combined.ts';
|
|
7
7
|
const defaultFormatExportTypeError = (name) => `The Edge Function "${name}" has failed to load. Does it have a function as the default export?`;
|
|
8
8
|
const defaultFormatImpoortError = (name) => `There was an error with Edge Function "${name}".`;
|
|
9
9
|
const generateStage2 = async ({ distDirectory, fileName, formatExportTypeError, formatImportError, functions, }) => {
|
package/dist/node/import_map.js
CHANGED
|
@@ -79,7 +79,7 @@ class ImportMap {
|
|
|
79
79
|
async writeToFile(path) {
|
|
80
80
|
const distDirectory = dirname(path);
|
|
81
81
|
await fs.mkdir(distDirectory, { recursive: true });
|
|
82
|
-
const contents = this.getContents(
|
|
82
|
+
const contents = this.getContents();
|
|
83
83
|
await fs.writeFile(path, JSON.stringify(contents));
|
|
84
84
|
}
|
|
85
85
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { promises as fs } from 'fs';
|
|
1
2
|
import { join } from 'path';
|
|
2
3
|
import { cwd } from 'process';
|
|
3
4
|
import { pathToFileURL } from 'url';
|
|
5
|
+
import tmp from 'tmp-promise';
|
|
4
6
|
import { test, expect } from 'vitest';
|
|
5
7
|
import { ImportMap } from './import_map.js';
|
|
6
8
|
test('Handles import maps with full URLs without specifying a base URL', () => {
|
|
@@ -67,3 +69,21 @@ test('Throws when an import map uses a relative path to reference a file outside
|
|
|
67
69
|
const map = new ImportMap([inputFile1]);
|
|
68
70
|
expect(() => map.getContents(basePath)).toThrowError(`Import map cannot reference '${join(cwd(), 'file.js')}' as it's outside of the base directory '${basePath}'`);
|
|
69
71
|
});
|
|
72
|
+
test('Writes import map file to disk', async () => {
|
|
73
|
+
const file = await tmp.file();
|
|
74
|
+
const basePath = join(cwd(), 'my-cool-site', 'import-map.json');
|
|
75
|
+
const inputFile1 = {
|
|
76
|
+
baseURL: pathToFileURL(basePath),
|
|
77
|
+
imports: {
|
|
78
|
+
'alias:pets': './heart/pets/file.ts',
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
const map = new ImportMap([inputFile1]);
|
|
82
|
+
await map.writeToFile(file.path);
|
|
83
|
+
const createdFile = await fs.readFile(file.path, 'utf8');
|
|
84
|
+
const { imports } = JSON.parse(createdFile);
|
|
85
|
+
const expectedPath = join(cwd(), 'my-cool-site', 'heart', 'pets', 'file.ts');
|
|
86
|
+
await file.cleanup();
|
|
87
|
+
expect(imports['netlify:edge']).toBe('https://edge.netlify.com/v1/index.ts');
|
|
88
|
+
expect(imports['alias:pets']).toBe(pathToFileURL(expectedPath).toString());
|
|
89
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/edge-bundler",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.5.0",
|
|
4
4
|
"description": "Intelligently prepare Netlify Edge Functions for deployment",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/node/index.js",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"nock": "^13.2.4",
|
|
67
67
|
"tar": "^6.1.11",
|
|
68
68
|
"typescript": "^4.5.4",
|
|
69
|
-
"vite": "^
|
|
69
|
+
"vite": "^4.0.0",
|
|
70
70
|
"vitest": "^0.25.0"
|
|
71
71
|
},
|
|
72
72
|
"engines": {
|