@netlify/edge-bundler 2.0.3 → 2.0.4

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.
@@ -1,6 +1,6 @@
1
- import { join, resolve } from 'path';
2
- import { fileURLToPath } from 'url';
1
+ import { join } from 'path';
3
2
  import { wrapBundleError } from '../bundle_error.js';
3
+ import { getPackagePath } from '../package_json.js';
4
4
  import { getFileHash } from '../utils/sha256.js';
5
5
  const bundleESZIP = async ({ basePath, buildID, debug, deno, distDirectory, functions, importMap, }) => {
6
6
  const extension = '.eszip';
@@ -26,9 +26,8 @@ const bundleESZIP = async ({ basePath, buildID, debug, deno, distDirectory, func
26
26
  return { extension, format: 'eszip2', hash };
27
27
  };
28
28
  const getESZIPBundler = () => {
29
- const url = new URL(import.meta.url);
30
- const pathname = fileURLToPath(url);
31
- const bundlerPath = resolve(pathname, '../../../deno/bundle.ts');
29
+ const packagePath = getPackagePath();
30
+ const bundlerPath = join(packagePath, 'deno', 'bundle.ts');
32
31
  return bundlerPath;
33
32
  };
34
33
  export { bundleESZIP as bundle };
@@ -1,2 +1,3 @@
1
+ declare const getPackagePath: () => string;
1
2
  declare const getPackageVersion: () => string;
2
- export { getPackageVersion };
3
+ export { getPackagePath, getPackageVersion };
@@ -1,12 +1,18 @@
1
1
  import { readFileSync } from 'fs';
2
+ import { dirname, join } from 'path';
2
3
  import { findUpSync } from 'find-up';
3
- const getPackageVersion = () => {
4
+ const getPackagePath = () => {
4
5
  const packageJSONPath = findUpSync('package.json', { cwd: import.meta.url });
6
+ // We should never get here, but let's show a somewhat useful error message.
5
7
  if (packageJSONPath === undefined) {
6
- return '';
8
+ throw new Error('Could not find `package.json` for `@netlify/edge-bundler`. Please try running `npm install` to reinstall your dependencies.');
7
9
  }
10
+ return dirname(packageJSONPath);
11
+ };
12
+ const getPackageVersion = () => {
13
+ const packagePath = getPackagePath();
8
14
  try {
9
- const packageJSON = readFileSync(packageJSONPath, 'utf8');
15
+ const packageJSON = readFileSync(join(packagePath, 'package.json'), 'utf8');
10
16
  const { version } = JSON.parse(packageJSON);
11
17
  return version;
12
18
  }
@@ -14,4 +20,4 @@ const getPackageVersion = () => {
14
20
  return '';
15
21
  }
16
22
  };
17
- export { getPackageVersion };
23
+ export { getPackagePath, getPackageVersion };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/edge-bundler",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "description": "Intelligently prepare Netlify Edge Functions for deployment",
5
5
  "type": "module",
6
6
  "main": "./dist/node/index.js",