@netlify/edge-bundler 6.0.0 → 6.1.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.
package/dist/node/bundler.js
CHANGED
|
@@ -47,7 +47,7 @@ const bundle = async (sourceDirectories, distDirectory, tomlDeclarations = [], {
|
|
|
47
47
|
}
|
|
48
48
|
if (featureFlags.edge_functions_read_deno_config) {
|
|
49
49
|
// Look for a Deno config file and read it if one exists.
|
|
50
|
-
const denoConfig = await getDenoConfig(basePath);
|
|
50
|
+
const denoConfig = await getDenoConfig(logger, basePath);
|
|
51
51
|
// If the Deno config file defines an import map, read the file and add the
|
|
52
52
|
// imports to the global import map.
|
|
53
53
|
if (denoConfig === null || denoConfig === void 0 ? void 0 : denoConfig.importMap) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { Logger } from './logger.js';
|
|
1
2
|
interface DenoConfigFile {
|
|
2
3
|
importMap?: string;
|
|
3
4
|
}
|
|
4
|
-
export declare const getConfig: (basePath?: string) => Promise<DenoConfigFile | undefined>;
|
|
5
|
+
export declare const getConfig: (logger: Logger, basePath?: string) => Promise<DenoConfigFile | undefined>;
|
|
5
6
|
export {};
|
package/dist/node/deno_config.js
CHANGED
|
@@ -3,17 +3,20 @@ import { join, resolve } from 'path';
|
|
|
3
3
|
import { parse as parseJSONC } from 'jsonc-parser';
|
|
4
4
|
import { isNodeError } from './utils/error.js';
|
|
5
5
|
const filenames = ['deno.json', 'deno.jsonc'];
|
|
6
|
-
export const getConfig = async (basePath) => {
|
|
6
|
+
export const getConfig = async (logger, basePath) => {
|
|
7
7
|
if (basePath === undefined) {
|
|
8
|
+
logger.system('No base path specified, will not attempt to read Deno config');
|
|
8
9
|
return;
|
|
9
10
|
}
|
|
10
11
|
for (const filename of filenames) {
|
|
11
12
|
const candidatePath = join(basePath, filename);
|
|
12
13
|
const config = await getConfigFromFile(candidatePath);
|
|
13
14
|
if (config !== undefined) {
|
|
15
|
+
logger.system('Loaded Deno config file from path', candidatePath);
|
|
14
16
|
return normalizeConfig(config, basePath);
|
|
15
17
|
}
|
|
16
18
|
}
|
|
19
|
+
logger.system('No Deno config file found at base path', basePath);
|
|
17
20
|
};
|
|
18
21
|
const getConfigFromFile = async (filePath) => {
|
|
19
22
|
try {
|
|
@@ -2,10 +2,11 @@ import { promises as fs } from 'fs';
|
|
|
2
2
|
import { join } from 'path';
|
|
3
3
|
import tmp from 'tmp-promise';
|
|
4
4
|
import { expect, test } from 'vitest';
|
|
5
|
+
import { testLogger } from '../test/util.js';
|
|
5
6
|
import { getConfig } from './deno_config.js';
|
|
6
7
|
test('Returns `undefined` if no config file is found', async () => {
|
|
7
8
|
const { cleanup, path } = await tmp.dir({ unsafeCleanup: true });
|
|
8
|
-
const config = await getConfig(path);
|
|
9
|
+
const config = await getConfig(testLogger, path);
|
|
9
10
|
expect(config).toBeUndefined();
|
|
10
11
|
await cleanup();
|
|
11
12
|
});
|
|
@@ -13,7 +14,7 @@ test('Returns an empty object if the config file cannot be parsed', async () =>
|
|
|
13
14
|
const { cleanup, path } = await tmp.dir({ unsafeCleanup: true });
|
|
14
15
|
const configPath = join(path, 'deno.json');
|
|
15
16
|
await fs.writeFile(configPath, '{');
|
|
16
|
-
const config = await getConfig(path);
|
|
17
|
+
const config = await getConfig(testLogger, path);
|
|
17
18
|
expect(config).toEqual({});
|
|
18
19
|
await cleanup();
|
|
19
20
|
});
|
|
@@ -22,7 +23,7 @@ test('Throws a type error if the `importMap` contains anything other than a stri
|
|
|
22
23
|
const configPath = join(path, 'deno.json');
|
|
23
24
|
const data = JSON.stringify({ importMap: { imports: { foo: './bar/' } } });
|
|
24
25
|
await fs.writeFile(configPath, data);
|
|
25
|
-
await expect(getConfig(path)).rejects.toThrowError(TypeError);
|
|
26
|
+
await expect(getConfig(testLogger, path)).rejects.toThrowError(TypeError);
|
|
26
27
|
await cleanup();
|
|
27
28
|
});
|
|
28
29
|
test('Excludes unsupported properties', async () => {
|
|
@@ -67,7 +68,7 @@ test('Excludes unsupported properties', async () => {
|
|
|
67
68
|
},
|
|
68
69
|
});
|
|
69
70
|
await fs.writeFile(configPath, data);
|
|
70
|
-
const config = await getConfig(path);
|
|
71
|
+
const config = await getConfig(testLogger, path);
|
|
71
72
|
expect(Object.keys(config !== null && config !== void 0 ? config : {})).toEqual(['importMap']);
|
|
72
73
|
await cleanup();
|
|
73
74
|
});
|
|
@@ -76,7 +77,7 @@ test('Resolves `importMap` into an absolute path', async () => {
|
|
|
76
77
|
const configPath = join(path, 'deno.json');
|
|
77
78
|
const data = JSON.stringify({ importMap: 'import_map.json' });
|
|
78
79
|
await fs.writeFile(configPath, data);
|
|
79
|
-
const config = await getConfig(path);
|
|
80
|
+
const config = await getConfig(testLogger, path);
|
|
80
81
|
expect(config).toEqual({ importMap: join(path, 'import_map.json') });
|
|
81
82
|
await cleanup();
|
|
82
83
|
});
|
|
@@ -85,7 +86,7 @@ test('Supports JSONC', async () => {
|
|
|
85
86
|
const configPath = join(path, 'deno.jsonc');
|
|
86
87
|
const data = JSON.stringify({ importMap: 'import_map.json' });
|
|
87
88
|
await fs.writeFile(configPath, `// This is a comment\n${data}`);
|
|
88
|
-
const config = await getConfig(path);
|
|
89
|
+
const config = await getConfig(testLogger, path);
|
|
89
90
|
expect(config).toEqual({ importMap: join(path, 'import_map.json') });
|
|
90
91
|
await cleanup();
|
|
91
92
|
});
|
|
@@ -73,7 +73,7 @@ const serve = async ({ basePath, certificatePath, debug, distImportMapPath, insp
|
|
|
73
73
|
// if any.
|
|
74
74
|
const importMap = new ImportMap(importMaps);
|
|
75
75
|
// Look for a Deno config file and read it if one exists.
|
|
76
|
-
const denoConfig = await getDenoConfig(basePath);
|
|
76
|
+
const denoConfig = await getDenoConfig(logger, basePath);
|
|
77
77
|
// If the Deno config file defines an import map, read the file and add the
|
|
78
78
|
// imports to the global import map.
|
|
79
79
|
if (denoConfig === null || denoConfig === void 0 ? void 0 : denoConfig.importMap) {
|