Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cli bundling import fix #1794

Merged
merged 10 commits into from
Nov 26, 2024
3 changes: 3 additions & 0 deletions packages/client/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ export function waitForTimeout() {

// Returns the package.json content at the package path.
export function getPackageJSON(rel) {
/* istanbul ignore else: sanity check */
if (process.env.PERCY_FORCE_EXECUTABLE_DIRNAME) rel = __dirname;

/* istanbul ignore else: sanity check */
if (rel.startsWith('file:')) rel = url.fileURLToPath(rel);

Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/api.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from 'fs';
import path from 'path';
import path, { dirname, resolve } from 'path';
import logger from '@percy/logger';
import { normalize } from '@percy/config/utils';
import { getPackageJSON, Server, percyAutomateRequestHandler, percyBuildEventHandler } from './utils.js';
Expand All @@ -11,7 +11,6 @@ import { handleSyncJob } from './snapshot.js';
// Now, we use `fileURLToPath` and `path.resolve` to determine the absolute path in a way that's more aligned with ESM conventions.
// This change ensures better compatibility and avoids relying on Node.js-specific APIs that might cause issues in ESM environments.
import { fileURLToPath } from 'url';
import { dirname, resolve } from 'path';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
Expand Down