magic-admin-js icon indicating copy to clipboard operation
magic-admin-js copied to clipboard

Upgrade to v2.1.0 from 2.0.1 breaks server dependencies because of dynamic import

Open ten-x-dev opened this issue 1 year ago • 0 comments

✅ Prerequisites

  • [x] Did you perform a cursory search of open issues? Is this bug already reported elsewhere?
  • [x] Are you running the latest SDK version?
  • [x] Are you reporting to the correct repository (@magic-sdk/admin)?

🐛 Description

Upgrading to the new version of magic breaks the server because of the dynamic import of the crypto module.

Run npx playwright test --project=chromium
[WebServer] Error: Dynamic require of "crypto" is not supported
    at file:///home/runner/work/french-house-stack/french-house-stack/build/index.js?t=1705785829014.18:12:9
    at node_modules/@noble/hashes/crypto.js (file:///home/runner/work/french-house-stack/french-house-stack/build/index.js?t=1705785829014.18:1[10](https://github.com/ten-x-dev/french-house-stack/actions/runs/7596904096/job/20691132649?pr=256#step:7:11)0:40)
    at file:///home/runner/work/french-house-stack/french-house-stack/build/index.js?t=1705785829014.18:1019:55
    at node_modules/@noble/hashes/utils.js (file:///home/runner/work/french-house-stack/french-house-stack/build/index.js?t=1705785829014.18:[11](https://github.com/ten-x-dev/french-house-stack/actions/runs/7596904096/job/20691132649?pr=256#step:7:12)10:24)
    at file:///home/runner/work/french-house-stack/french-house-stack/build/index.js?t=1705785829014.18:1019:55
    at node_modules/@noble/hashes/sha3.js (file:///home/runner/work/french-house-stack/french-house-stack/build/index.js?t=1705785829014.18:[12](https://github.com/ten-x-dev/french-house-stack/actions/runs/7596904096/job/20691132649?pr=256#step:7:13)62:61)
    at file:///home/runner/work/french-house-stack/french-house-stack/build/index.js?t=1705785829014.18:1019:55
    at node_modules/ethereum-cryptography/keccak.js (file:///home/runner/work/french-house-stack/french-house-stack/build/index.js?t=17057858290[14](https://github.com/ten-x-dev/french-house-stack/actions/runs/7596904096/job/20691132649?pr=256#step:7:15).18:1445:33)
    at file:///home/runner/work/french-house-stack/french-house-stack/build/index.js?t=1705785829014.18:1019:55
    at node_modules/@magic-sdk/admin/dist/esm/index.js (file:///home/runner/work/french-house-stack/french-house-stack/build/index.js?t=[17](https://github.com/ten-x-dev/french-house-stack/actions/runs/7596904096/job/20691132649?pr=256#step:7:18)05785829014.[18](https://github.com/ten-x-dev/french-house-stack/actions/runs/7596904096/job/20691132649?pr=256#step:7:19):4331:34)
    ```

### 🧩 Steps to Reproduce

Import it on the server and run in CI.

### 🤔 Expected behavior

Not to break 😊 

### 😮 Actual behavior

It blows up.

### 💻 Code Sample

Simply create a new Remix app with ESM and import Magic on the server.

### 🌎 Environment

| Software           | Version(s) |
| ------------------ | ---------- |
| `@magic-sdk/admin` | 2.1.0
| Node               |  20.10.0
| `yarn`             | N/A
| Operating System   | iOS

ten-x-dev avatar Jan 20 '24 21:01 ten-x-dev