@netlify/edge-bundler 9.4.1 → 9.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.
Files changed (30) hide show
  1. package/deno/lib/common.ts +2 -2
  2. package/deno/lib/stage2.ts +1 -1
  3. package/deno/vendor/deno.land/x/dir@1.5.1/data_local_dir/mod.ts +34 -0
  4. package/deno/vendor/deno.land/x/{eszip@v0.40.0 → eszip@v0.55.2}/eszip_wasm.generated.js +136 -179
  5. package/deno/vendor/deno.land/x/eszip@v0.55.2/eszip_wasm_bg.wasm +0 -0
  6. package/deno/vendor/deno.land/x/wasmbuild@0.15.1/cache.ts +157 -0
  7. package/deno/vendor/deno.land/x/wasmbuild@0.15.1/loader.ts +126 -0
  8. package/dist/node/bridge.d.ts +1 -1
  9. package/dist/node/bridge.js +1 -1
  10. package/dist/node/bundler.js +1 -4
  11. package/dist/node/bundler.test.js +23 -48
  12. package/dist/node/feature_flags.d.ts +2 -8
  13. package/dist/node/feature_flags.js +1 -4
  14. package/dist/node/formats/eszip.d.ts +1 -1
  15. package/dist/node/formats/eszip.js +2 -2
  16. package/dist/node/formats/javascript.js +1 -2
  17. package/dist/node/manifest.d.ts +1 -1
  18. package/dist/node/manifest.js +7 -16
  19. package/dist/node/manifest.test.js +2 -19
  20. package/dist/node/npm_dependencies.d.ts +1 -0
  21. package/dist/node/npm_dependencies.js +2 -0
  22. package/dist/node/npm_import_error.d.ts +2 -2
  23. package/dist/node/npm_import_error.js +5 -9
  24. package/dist/node/server/server.js +29 -15
  25. package/dist/node/server/server.test.js +0 -3
  26. package/dist/test/util.js +1 -1
  27. package/package.json +1 -1
  28. package/deno/vendor/deno.land/x/eszip@v0.40.0/eszip_wasm_bg.wasm +0 -0
  29. /package/deno/vendor/deno.land/x/{eszip@v0.40.0 → eszip@v0.55.2}/loader.ts +0 -0
  30. /package/deno/vendor/deno.land/x/{eszip@v0.40.0 → eszip@v0.55.2}/mod.ts +0 -0
@@ -1,3 +1,5 @@
1
+ import { readdir, unlink } from 'fs/promises';
2
+ import { join } from 'path';
1
3
  import { DenoBridge } from '../bridge.js';
2
4
  import { getFunctionConfig } from '../config.js';
3
5
  import { generateStage2 } from '../formats/javascript.js';
@@ -6,7 +8,17 @@ import { getLogger } from '../logger.js';
6
8
  import { vendorNPMSpecifiers } from '../npm_dependencies.js';
7
9
  import { ensureLatestTypes } from '../types.js';
8
10
  import { killProcess, waitForServer } from './util.js';
9
- const prepareServer = ({ basePath, bootstrapURL, deno, distDirectory, distImportMapPath, featureFlags, flags: denoFlags, formatExportTypeError, formatImportError, importMap: baseImportMap, logger, port, }) => {
11
+ /**
12
+ * Cleans up a directory, except for the files specified in the `except` array.
13
+ * Both should be given as absolute paths.
14
+ * Assumes the directory doesn't contain any nested directories.
15
+ */
16
+ const cleanDirectory = async (directory, except) => {
17
+ const files = await readdir(directory);
18
+ const toBeDeleted = files.filter((file) => !except.includes(join(directory, file)));
19
+ await Promise.all(toBeDeleted.map((file) => unlink(join(directory, file))));
20
+ };
21
+ const prepareServer = ({ basePath, bootstrapURL, deno, distDirectory, distImportMapPath, flags: denoFlags, formatExportTypeError, formatImportError, importMap: baseImportMap, logger, port, }) => {
10
22
  const processRef = {};
11
23
  const startServer = async (functions, env = {}, options = {}) => {
12
24
  if ((processRef === null || processRef === void 0 ? void 0 : processRef.ps) !== undefined) {
@@ -24,21 +36,23 @@ const prepareServer = ({ basePath, bootstrapURL, deno, distDirectory, distImport
24
36
  const features = {};
25
37
  const importMap = baseImportMap.clone();
26
38
  const npmSpecifiersWithExtraneousFiles = [];
27
- if (featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.edge_functions_npm_modules) {
28
- const vendor = await vendorNPMSpecifiers({
29
- basePath,
30
- directory: distDirectory,
31
- functions: functions.map(({ path }) => path),
32
- importMap,
33
- logger,
34
- referenceTypes: true,
35
- });
36
- if (vendor) {
37
- features.npmModules = true;
38
- importMap.add(vendor.importMap);
39
- npmSpecifiersWithExtraneousFiles.push(...vendor.npmSpecifiersWithExtraneousFiles);
40
- }
39
+ // we keep track of the files that are relevant to the user's code, so we can clean up leftovers from past executions later
40
+ const relevantFiles = [stage2Path];
41
+ const vendor = await vendorNPMSpecifiers({
42
+ basePath,
43
+ directory: distDirectory,
44
+ functions: functions.map(({ path }) => path),
45
+ importMap,
46
+ logger,
47
+ referenceTypes: true,
48
+ });
49
+ if (vendor) {
50
+ features.npmModules = true;
51
+ importMap.add(vendor.importMap);
52
+ npmSpecifiersWithExtraneousFiles.push(...vendor.npmSpecifiersWithExtraneousFiles);
53
+ relevantFiles.push(...vendor.outputFiles);
41
54
  }
55
+ await cleanDirectory(distDirectory, relevantFiles);
42
56
  try {
43
57
  // This command will print a JSON object with all the modules found in
44
58
  // the `stage2Path` file as well as all of their dependencies.
@@ -21,9 +21,6 @@ test('Starts a server and serves requests for edge functions', async () => {
21
21
  importMapPaths,
22
22
  port,
23
23
  servePath,
24
- featureFlags: {
25
- edge_functions_npm_modules: true,
26
- },
27
24
  });
28
25
  const functions = [
29
26
  {
package/dist/test/util.js CHANGED
@@ -55,7 +55,7 @@ const runESZIP = async (eszipPath, vendorDirectory) => {
55
55
  const extractCommand = execa('deno', [
56
56
  'run',
57
57
  '--allow-all',
58
- 'https://deno.land/x/eszip@v0.40.0/eszip.ts',
58
+ 'https://deno.land/x/eszip@v0.55.2/eszip.ts',
59
59
  'x',
60
60
  eszipPath,
61
61
  tmpDir.path,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/edge-bundler",
3
- "version": "9.4.1",
3
+ "version": "9.5.0",
4
4
  "description": "Intelligently prepare Netlify Edge Functions for deployment",
5
5
  "type": "module",
6
6
  "main": "./dist/node/index.js",