diff --git a/package.json b/package.json index 4e48860a..622cea7f 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "@google-cloud/bigquery": "^8.3.1", "@google-cloud/firestore": "^7.6.0", "@opentelemetry/api": "^1.7.0", + "@paypal/paypal-js": "10.0.1", "@sentry/node": "^9.2.0", "@tpluscode/sparql-builder": "^0.3.12", "@types/bindings": "^1.3.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 04f9a5b4..8628cbe9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -69,6 +69,9 @@ importers: '@opentelemetry/api': specifier: ^1.7.0 version: 1.9.0 + '@paypal/paypal-js': + specifier: 10.0.1 + version: 10.0.1 '@sentry/node': specifier: ^9.2.0 version: 9.47.1 @@ -2093,6 +2096,9 @@ packages: '@paulirish/trace_engine@0.0.61': resolution: {integrity: sha512-/O08DwmUqIlJjUSPSZbNF8lWnlxaMsIOV6sS+uDKCxBd5i1psAmjEoG3JAqR6+nHD8X+YY474NW7SxUH/K+/kQ==} + '@paypal/paypal-js@10.0.1': + resolution: {integrity: sha512-tVv2p5Wf4YyI3BNa2dx5uRIM0iWi5Ci8dn1yUjwAml7Q+axmyTH5maWkCUBktD6Gmw/AjPBv4lRbkHFZyfH8uQ==} + '@phc/format@1.0.0': resolution: {integrity: sha512-m7X9U6BG2+J+R1lSOdCiITLLrxm+cWlNI3HUFA92oLO77ObGNzaKdh8pMLqdZcshtkKuV84olNNXDfMc4FezBQ==} engines: {node: '>=10'} @@ -7805,6 +7811,9 @@ packages: promise-polyfill@1.1.6: resolution: {integrity: sha512-7rrONfyLkDEc7OJ5QBkqa4KI4EBhCd340xRuIUPGCfu13znS+vx+VDdrT9ODAJHlXm7w4lbxN3DRjyv58EuzDg==} + promise-polyfill@8.3.0: + resolution: {integrity: sha512-H5oELycFml5yto/atYqmjyigJoAo3+OXwolYiH7OfQuYlAqhxNvTfiNMbV9hsC6Yp83yE5r2KTVmtrG6R9i6Pg==} + promise-the-world@1.0.1: resolution: {integrity: sha512-eAXctcYU0ksq9YT5LT0N3e8yvdEAp0aYuzIiaJo9CpZwga45i08MW05GMXZIow7N05d1o4EBoR5hjkb7jhzqKg==} @@ -12247,6 +12256,10 @@ snapshots: legacy-javascript: 0.0.1 third-party-web: 0.29.2 + '@paypal/paypal-js@10.0.1': + dependencies: + promise-polyfill: 8.3.0 + '@phc/format@1.0.0': {} '@pkgjs/parseargs@0.11.0': @@ -19290,6 +19303,8 @@ snapshots: promise-polyfill@1.1.6: {} + promise-polyfill@8.3.0: {} + promise-the-world@1.0.1: {} promise@7.3.1: diff --git a/test/integration/paypal-js-sdk-v6.mjs b/test/integration/paypal-js-sdk-v6.mjs new file mode 100644 index 00000000..9fe48521 --- /dev/null +++ b/test/integration/paypal-js-sdk-v6.mjs @@ -0,0 +1,11 @@ +// Regression test for https://github.com/vercel/nft/issues/599 +// @paypal/paypal-js@10.0.1 exposes ./sdk-v6 with only "types" + "import" +// conditions. Tracing must include dist/v6/esm/paypal-js.js so the named +// export loadCoreSdkScript resolves at runtime after packaging. +import { loadCoreSdkScript } from '@paypal/paypal-js/sdk-v6'; + +if (typeof loadCoreSdkScript !== 'function') { + throw new Error( + `Expected loadCoreSdkScript to be a function, got ${typeof loadCoreSdkScript}`, + ); +} diff --git a/test/unit.test.js b/test/unit.test.js index 662ae82b..3781a1c3 100644 --- a/test/unit.test.js +++ b/test/unit.test.js @@ -153,7 +153,8 @@ for (const { testName, isRoot } of unitTests) { testName === 'module-create-require-named-require' || testName === 'module-create-require-named-import' || testName === 'module-create-require-ignore-other' || - testName === 'module-create-require-destructure' + testName === 'module-create-require-destructure' || + testName === 'paypal-js-sdk-v6' ) { inputFileNames = ['input.mjs']; } diff --git a/test/unit/paypal-js-sdk-v6/input.mjs b/test/unit/paypal-js-sdk-v6/input.mjs new file mode 100644 index 00000000..5d28d150 --- /dev/null +++ b/test/unit/paypal-js-sdk-v6/input.mjs @@ -0,0 +1,3 @@ +import { loadCoreSdkScript } from '@paypal/paypal-js/sdk-v6'; + +console.log(typeof loadCoreSdkScript); diff --git a/test/unit/paypal-js-sdk-v6/output.js b/test/unit/paypal-js-sdk-v6/output.js new file mode 100644 index 00000000..64b6d074 --- /dev/null +++ b/test/unit/paypal-js-sdk-v6/output.js @@ -0,0 +1,5 @@ +[ + "node_modules/@paypal/paypal-js/dist/v6/esm/paypal-js.js", + "node_modules/@paypal/paypal-js/package.json", + "test/unit/paypal-js-sdk-v6/input.mjs" +]