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 #1785

Merged
merged 7 commits into from
Nov 20, 2024

Conversation

khushhalm
Copy link
Contributor

Previously, we used createRequire(import.meta.url).resolve to resolve the path to the module.
This approach relied on createRequire, which is Node.js-specific and less compatible with modern ESM (ECMAScript Module) standards.
This was leading to hard coded paths when CLI is used as a dependency in another project.
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.

Old code:

export const PERCY_DOM = createRequire(import.meta.url).resolve('@percy/dom');

New code:

import { fileURLToPath } from 'url';
import { dirname, resolve } from 'path';

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

export const PERCY_DOM = resolve(__dirname, 'node_modules/@percy/dom');

@khushhalm khushhalm requested a review from a team as a code owner November 20, 2024 03:42
@khushhalm khushhalm requested review from pankaj443 and ninadbstack and removed request for a team November 20, 2024 03:42
@prklm10 prklm10 merged commit cacd660 into percy:pac-file-support Nov 20, 2024
21 of 34 checks passed
prklm10 added a commit that referenced this pull request Jan 9, 2025
* PAC file support via PERCY_PAC_FILE_URL env var (#1784)

* PAC file support via PERCY_PAC_FILE_PATH env var

* Added pac-proxy-agent lib as dependency

* typo fixes

* PR comments addressed

* Moved pac-proxy-agent lib dependency to percy client instead of main package

* Resolved conflicts

* Fix import in ternary statement (#1779)

* Fix import in ternary statement

* Added comment

* Typo fix in comment

Co-authored-by: ninadbstack <60422475+ninadbstack@users.noreply.github.com>

* Removed trailing space

---------

Co-authored-by: ninadbstack <60422475+ninadbstack@users.noreply.github.com>

* v1.30.3-alpha.0

* Cli bundling import fix (#1785)

* Fix import in ternary statement

* Added comment

* Typo fix in comment

Co-authored-by: ninadbstack <60422475+ninadbstack@users.noreply.github.com>

* Removed trailing space

* Fix import of PERCY_DOM in line w ESM req

* made a minor comment change

---------

Co-authored-by: ninadbstack <60422475+ninadbstack@users.noreply.github.com>

* v1.30.3-alpha.1

* v1.30.3-alpha.2

* Cli bundling import fix (#1794)

* Fix import in ternary statement

* Added comment

* Typo fix in comment

Co-authored-by: ninadbstack <60422475+ninadbstack@users.noreply.github.com>

* Removed trailing space

* Fix import of PERCY_DOM in line w ESM req

* made a minor comment change

* Added PERCY_FORCE_DIRNAME flag in getPackageJSON util method

* Env var name updated to PERCY_FORCE_EXECUTABLE_DIRNAME

Co-authored-by: ninadbstack <60422475+ninadbstack@users.noreply.github.com>

---------

Co-authored-by: ninadbstack <60422475+ninadbstack@users.noreply.github.com>

* v1.30.3-alpha.3

* Added PERCY_FORCE_PKG_VALUE in place of PERCY_FORCE_DIRNAME (#1799)

* Added PERCY_FORCE_PKG_VALUE in place of PERCY_FORCE_DIRNAME

* Bumped the percy tag to 1.30.3-alpha.4

* Added PERCY_FORCE_PKG_VALUE in env file and using from there (#1800)

* Added PERCY_FORCE_PKG_VALUE in place of PERCY_FORCE_DIRNAME

* Bumped the percy tag to 1.30.3-alpha.4

* Added PERCY_FORCE_PKG_VALUE in env file and using from there

* Bumped the percy tag to 1.30.3-alpha.5

* fixed linting

* client-fix

* upload-cli-fix

* cli-build-fix

* cli-exec-fix

* cli-snapshot-fix

* MERGE_COMMIT

* MERGE_COMMIT

* Proxy.test

* proxy

* core fixed

* client package

* client package

* client package

* client package

* client package

* lock file

* pac-packages

* pac-packages

* pac-packages

* lint pass

* lint pass

* lint pass

* lint pass

* proxy pass

* client pass

* api-test

* api-test

* percy-test-cases

* Removed find revision

* lint-fix

---------

Co-authored-by: Khushhal Maheshwari <25052873+khushhalm@users.noreply.github.com>
Co-authored-by: ninadbstack <60422475+ninadbstack@users.noreply.github.com>
Co-authored-by: Ninad Sheth <ninad@browserstack.com>
Co-authored-by: prklm10 <pradumraj360@gmail.com>
Co-authored-by: Mukul Bhutiani <mukul.b@browserstack.com>
amandeepsingh333 pushed a commit that referenced this pull request Jan 10, 2025
* PAC file support via PERCY_PAC_FILE_URL env var (#1784)

* PAC file support via PERCY_PAC_FILE_PATH env var

* Added pac-proxy-agent lib as dependency

* typo fixes

* PR comments addressed

* Moved pac-proxy-agent lib dependency to percy client instead of main package

* Resolved conflicts

* Fix import in ternary statement (#1779)

* Fix import in ternary statement

* Added comment

* Typo fix in comment

Co-authored-by: ninadbstack <60422475+ninadbstack@users.noreply.github.com>

* Removed trailing space

---------

Co-authored-by: ninadbstack <60422475+ninadbstack@users.noreply.github.com>

* v1.30.3-alpha.0

* Cli bundling import fix (#1785)

* Fix import in ternary statement

* Added comment

* Typo fix in comment

Co-authored-by: ninadbstack <60422475+ninadbstack@users.noreply.github.com>

* Removed trailing space

* Fix import of PERCY_DOM in line w ESM req

* made a minor comment change

---------

Co-authored-by: ninadbstack <60422475+ninadbstack@users.noreply.github.com>

* v1.30.3-alpha.1

* v1.30.3-alpha.2

* Cli bundling import fix (#1794)

* Fix import in ternary statement

* Added comment

* Typo fix in comment

Co-authored-by: ninadbstack <60422475+ninadbstack@users.noreply.github.com>

* Removed trailing space

* Fix import of PERCY_DOM in line w ESM req

* made a minor comment change

* Added PERCY_FORCE_DIRNAME flag in getPackageJSON util method

* Env var name updated to PERCY_FORCE_EXECUTABLE_DIRNAME

Co-authored-by: ninadbstack <60422475+ninadbstack@users.noreply.github.com>

---------

Co-authored-by: ninadbstack <60422475+ninadbstack@users.noreply.github.com>

* v1.30.3-alpha.3

* Added PERCY_FORCE_PKG_VALUE in place of PERCY_FORCE_DIRNAME (#1799)

* Added PERCY_FORCE_PKG_VALUE in place of PERCY_FORCE_DIRNAME

* Bumped the percy tag to 1.30.3-alpha.4

* Added PERCY_FORCE_PKG_VALUE in env file and using from there (#1800)

* Added PERCY_FORCE_PKG_VALUE in place of PERCY_FORCE_DIRNAME

* Bumped the percy tag to 1.30.3-alpha.4

* Added PERCY_FORCE_PKG_VALUE in env file and using from there

* Bumped the percy tag to 1.30.3-alpha.5

* fixed linting

* client-fix

* upload-cli-fix

* cli-build-fix

* cli-exec-fix

* cli-snapshot-fix

* MERGE_COMMIT

* MERGE_COMMIT

* Proxy.test

* proxy

* core fixed

* client package

* client package

* client package

* client package

* client package

* lock file

* pac-packages

* pac-packages

* pac-packages

* lint pass

* lint pass

* lint pass

* lint pass

* proxy pass

* client pass

* api-test

* api-test

* percy-test-cases

* Removed find revision

* lint-fix

---------

Co-authored-by: Khushhal Maheshwari <25052873+khushhalm@users.noreply.github.com>
Co-authored-by: ninadbstack <60422475+ninadbstack@users.noreply.github.com>
Co-authored-by: Ninad Sheth <ninad@browserstack.com>
Co-authored-by: prklm10 <pradumraj360@gmail.com>
Co-authored-by: Mukul Bhutiani <mukul.b@browserstack.com>
amandeepsingh333 pushed a commit that referenced this pull request Jan 10, 2025
* PAC file support via PERCY_PAC_FILE_URL env var (#1784)

* PAC file support via PERCY_PAC_FILE_PATH env var

* Added pac-proxy-agent lib as dependency

* typo fixes

* PR comments addressed

* Moved pac-proxy-agent lib dependency to percy client instead of main package

* Resolved conflicts

* Fix import in ternary statement (#1779)

* Fix import in ternary statement

* Added comment

* Typo fix in comment

Co-authored-by: ninadbstack <60422475+ninadbstack@users.noreply.github.com>

* Removed trailing space

---------

Co-authored-by: ninadbstack <60422475+ninadbstack@users.noreply.github.com>

* v1.30.3-alpha.0

* Cli bundling import fix (#1785)

* Fix import in ternary statement

* Added comment

* Typo fix in comment

Co-authored-by: ninadbstack <60422475+ninadbstack@users.noreply.github.com>

* Removed trailing space

* Fix import of PERCY_DOM in line w ESM req

* made a minor comment change

---------

Co-authored-by: ninadbstack <60422475+ninadbstack@users.noreply.github.com>

* v1.30.3-alpha.1

* v1.30.3-alpha.2

* Cli bundling import fix (#1794)

* Fix import in ternary statement

* Added comment

* Typo fix in comment

Co-authored-by: ninadbstack <60422475+ninadbstack@users.noreply.github.com>

* Removed trailing space

* Fix import of PERCY_DOM in line w ESM req

* made a minor comment change

* Added PERCY_FORCE_DIRNAME flag in getPackageJSON util method

* Env var name updated to PERCY_FORCE_EXECUTABLE_DIRNAME

Co-authored-by: ninadbstack <60422475+ninadbstack@users.noreply.github.com>

---------

Co-authored-by: ninadbstack <60422475+ninadbstack@users.noreply.github.com>

* v1.30.3-alpha.3

* Added PERCY_FORCE_PKG_VALUE in place of PERCY_FORCE_DIRNAME (#1799)

* Added PERCY_FORCE_PKG_VALUE in place of PERCY_FORCE_DIRNAME

* Bumped the percy tag to 1.30.3-alpha.4

* Added PERCY_FORCE_PKG_VALUE in env file and using from there (#1800)

* Added PERCY_FORCE_PKG_VALUE in place of PERCY_FORCE_DIRNAME

* Bumped the percy tag to 1.30.3-alpha.4

* Added PERCY_FORCE_PKG_VALUE in env file and using from there

* Bumped the percy tag to 1.30.3-alpha.5

* fixed linting

* client-fix

* upload-cli-fix

* cli-build-fix

* cli-exec-fix

* cli-snapshot-fix

* MERGE_COMMIT

* MERGE_COMMIT

* Proxy.test

* proxy

* core fixed

* client package

* client package

* client package

* client package

* client package

* lock file

* pac-packages

* pac-packages

* pac-packages

* lint pass

* lint pass

* lint pass

* lint pass

* proxy pass

* client pass

* api-test

* api-test

* percy-test-cases

* Removed find revision

* lint-fix

---------

Co-authored-by: Khushhal Maheshwari <25052873+khushhalm@users.noreply.github.com>
Co-authored-by: ninadbstack <60422475+ninadbstack@users.noreply.github.com>
Co-authored-by: Ninad Sheth <ninad@browserstack.com>
Co-authored-by: prklm10 <pradumraj360@gmail.com>
Co-authored-by: Mukul Bhutiani <mukul.b@browserstack.com>
amandeepsingh333 added a commit that referenced this pull request Jan 23, 2025
* updated chromium revisions for 131

* testing failed snapshots

* testing errors

* testing

* testing with prev version

* fixed test for discovery

* Adding a different concurrency count for snapshot processing for Cs (#1814)

* updated snapshot concurrency

* Removing the build script

* lint fix

* Fixing few cases

* 🔖 v1.31.0-alpha.0

* 🔖 v1.31.0-alpha.0 lerna.json

* Adding Error Capturing on Finalize Builds (#1818)

* Adding Error Capturing on Finalize Builds

* 🔖 v1.31.0-alpha.1

* 🔖 v1.31.0-alpha.2

* Adding prodBuild param for scanner alt env (#1830)

* Adding prodBuild param for scanner alt env

* renaming config

---------

Co-authored-by: rishigupta1599 <114384996+rishigupta1599@users.noreply.github.com>

* 🔖 v1.31.0-alpha.0 lerna.json

* Removing unwanted files

* 🔖 v1.31.0-alpha.3

* Add tests + fix concurrency

* Undo package json changes

---------

Co-authored-by: amit3200 <tusharamit@yahoo.com>
Co-authored-by: rishigupta1599 <114384996+rishigupta1599@users.noreply.github.com>
Co-authored-by: rishigupta1599 <rishi@browserstack.com>
Co-authored-by: Chinmay Maheshwari <chinmay.m@browserstack.com>

* 🔖 v1.30.6-beta.0 (#1833)

* Release v1.30.6-beta.0

* Update tag to beta

* Release v1.30.6 (#1835)

* Pac file test (#1829)

* PAC file support via PERCY_PAC_FILE_URL env var (#1784)

* PAC file support via PERCY_PAC_FILE_PATH env var

* Added pac-proxy-agent lib as dependency

* typo fixes

* PR comments addressed

* Moved pac-proxy-agent lib dependency to percy client instead of main package

* Resolved conflicts

* Fix import in ternary statement (#1779)

* Fix import in ternary statement

* Added comment

* Typo fix in comment

Co-authored-by: ninadbstack <60422475+ninadbstack@users.noreply.github.com>

* Removed trailing space

---------

Co-authored-by: ninadbstack <60422475+ninadbstack@users.noreply.github.com>

* v1.30.3-alpha.0

* Cli bundling import fix (#1785)

* Fix import in ternary statement

* Added comment

* Typo fix in comment

Co-authored-by: ninadbstack <60422475+ninadbstack@users.noreply.github.com>

* Removed trailing space

* Fix import of PERCY_DOM in line w ESM req

* made a minor comment change

---------

Co-authored-by: ninadbstack <60422475+ninadbstack@users.noreply.github.com>

* v1.30.3-alpha.1

* v1.30.3-alpha.2

* Cli bundling import fix (#1794)

* Fix import in ternary statement

* Added comment

* Typo fix in comment

Co-authored-by: ninadbstack <60422475+ninadbstack@users.noreply.github.com>

* Removed trailing space

* Fix import of PERCY_DOM in line w ESM req

* made a minor comment change

* Added PERCY_FORCE_DIRNAME flag in getPackageJSON util method

* Env var name updated to PERCY_FORCE_EXECUTABLE_DIRNAME

Co-authored-by: ninadbstack <60422475+ninadbstack@users.noreply.github.com>

---------

Co-authored-by: ninadbstack <60422475+ninadbstack@users.noreply.github.com>

* v1.30.3-alpha.3

* Added PERCY_FORCE_PKG_VALUE in place of PERCY_FORCE_DIRNAME (#1799)

* Added PERCY_FORCE_PKG_VALUE in place of PERCY_FORCE_DIRNAME

* Bumped the percy tag to 1.30.3-alpha.4

* Added PERCY_FORCE_PKG_VALUE in env file and using from there (#1800)

* Added PERCY_FORCE_PKG_VALUE in place of PERCY_FORCE_DIRNAME

* Bumped the percy tag to 1.30.3-alpha.4

* Added PERCY_FORCE_PKG_VALUE in env file and using from there

* Bumped the percy tag to 1.30.3-alpha.5

* fixed linting

* client-fix

* upload-cli-fix

* cli-build-fix

* cli-exec-fix

* cli-snapshot-fix

* MERGE_COMMIT

* MERGE_COMMIT

* Proxy.test

* proxy

* core fixed

* client package

* client package

* client package

* client package

* client package

* lock file

* pac-packages

* pac-packages

* pac-packages

* lint pass

* lint pass

* lint pass

* lint pass

* proxy pass

* client pass

* api-test

* api-test

* percy-test-cases

* Removed find revision

* lint-fix

---------

Co-authored-by: Khushhal Maheshwari <25052873+khushhalm@users.noreply.github.com>
Co-authored-by: ninadbstack <60422475+ninadbstack@users.noreply.github.com>
Co-authored-by: Ninad Sheth <ninad@browserstack.com>
Co-authored-by: prklm10 <pradumraj360@gmail.com>
Co-authored-by: Mukul Bhutiani <mukul.b@browserstack.com>

* Revert "Pac file test (#1829)" (#1838)

* Pac file test (#1829)

* PAC file support via PERCY_PAC_FILE_URL env var (#1784)

* PAC file support via PERCY_PAC_FILE_PATH env var

* Added pac-proxy-agent lib as dependency

* typo fixes

* PR comments addressed

* Moved pac-proxy-agent lib dependency to percy client instead of main package

* Resolved conflicts

* Fix import in ternary statement (#1779)

* Fix import in ternary statement

* Added comment

* Typo fix in comment

Co-authored-by: ninadbstack <60422475+ninadbstack@users.noreply.github.com>

* Removed trailing space

---------

Co-authored-by: ninadbstack <60422475+ninadbstack@users.noreply.github.com>

* v1.30.3-alpha.0

* Cli bundling import fix (#1785)

* Fix import in ternary statement

* Added comment

* Typo fix in comment

Co-authored-by: ninadbstack <60422475+ninadbstack@users.noreply.github.com>

* Removed trailing space

* Fix import of PERCY_DOM in line w ESM req

* made a minor comment change

---------

Co-authored-by: ninadbstack <60422475+ninadbstack@users.noreply.github.com>

* v1.30.3-alpha.1

* v1.30.3-alpha.2

* Cli bundling import fix (#1794)

* Fix import in ternary statement

* Added comment

* Typo fix in comment

Co-authored-by: ninadbstack <60422475+ninadbstack@users.noreply.github.com>

* Removed trailing space

* Fix import of PERCY_DOM in line w ESM req

* made a minor comment change

* Added PERCY_FORCE_DIRNAME flag in getPackageJSON util method

* Env var name updated to PERCY_FORCE_EXECUTABLE_DIRNAME

Co-authored-by: ninadbstack <60422475+ninadbstack@users.noreply.github.com>

---------

Co-authored-by: ninadbstack <60422475+ninadbstack@users.noreply.github.com>

* v1.30.3-alpha.3

* Added PERCY_FORCE_PKG_VALUE in place of PERCY_FORCE_DIRNAME (#1799)

* Added PERCY_FORCE_PKG_VALUE in place of PERCY_FORCE_DIRNAME

* Bumped the percy tag to 1.30.3-alpha.4

* Added PERCY_FORCE_PKG_VALUE in env file and using from there (#1800)

* Added PERCY_FORCE_PKG_VALUE in place of PERCY_FORCE_DIRNAME

* Bumped the percy tag to 1.30.3-alpha.4

* Added PERCY_FORCE_PKG_VALUE in env file and using from there

* Bumped the percy tag to 1.30.3-alpha.5

* fixed linting

* client-fix

* upload-cli-fix

* cli-build-fix

* cli-exec-fix

* cli-snapshot-fix

* MERGE_COMMIT

* MERGE_COMMIT

* Proxy.test

* proxy

* core fixed

* client package

* client package

* client package

* client package

* client package

* lock file

* pac-packages

* pac-packages

* pac-packages

* lint pass

* lint pass

* lint pass

* lint pass

* proxy pass

* client pass

* api-test

* api-test

* percy-test-cases

* Removed find revision

* lint-fix

---------

Co-authored-by: Khushhal Maheshwari <25052873+khushhalm@users.noreply.github.com>
Co-authored-by: ninadbstack <60422475+ninadbstack@users.noreply.github.com>
Co-authored-by: Ninad Sheth <ninad@browserstack.com>
Co-authored-by: prklm10 <pradumraj360@gmail.com>
Co-authored-by: Mukul Bhutiani <mukul.b@browserstack.com>

* Revert "Pac file test (#1829)" (#1838)

* fixed cli-exec

* upgraded to 128

* removed comment

* 126

* tests

---------

Co-authored-by: revathySV@Browserstack <112399938+revathySV@users.noreply.github.com>
Co-authored-by: amit3200 <tusharamit@yahoo.com>
Co-authored-by: rishigupta1599 <114384996+rishigupta1599@users.noreply.github.com>
Co-authored-by: rishigupta1599 <rishi@browserstack.com>
Co-authored-by: Chinmay Maheshwari <chinmay.m@browserstack.com>
Co-authored-by: chinmay-browserstack <92926953+chinmay-browserstack@users.noreply.github.com>
Co-authored-by: MuCool <68110864+bhutianimukul@users.noreply.github.com>
Co-authored-by: Khushhal Maheshwari <25052873+khushhalm@users.noreply.github.com>
Co-authored-by: ninadbstack <60422475+ninadbstack@users.noreply.github.com>
Co-authored-by: Ninad Sheth <ninad@browserstack.com>
Co-authored-by: prklm10 <pradumraj360@gmail.com>
Co-authored-by: Mukul Bhutiani <mukul.b@browserstack.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants