fireproof-storage / fireproof

Realtime database, runs anywhere. Install Fireproof in your front-end app or edge function, and sync data via any backend.
https://fireproof.storage
Other
314 stars 17 forks source link

connector packaging issues #349

Open mschoch opened 3 days ago

mschoch commented 3 days ago

I'm able to use fireproof v0.19 + partykit with the IIFE builds, however I have another app which is a react app, and upgrading it to v0.19 fails with the following:

pnpm build

> fireplace-admin@0.1.0 build /home/mschoch/research/fireplace-admin
> react-scripts build

Creating an optimized production build...
Failed to compile.

Module not found: Error: Can't resolve 'path' in '/home/mschoch/research/fireplace-admin/node_modules/.pnpm/memfs@4.14.0/node_modules/memfs/lib'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
    - add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
    - install 'path-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
    resolve.fallback: { "path": false }

 ELIFECYCLE  Command failed with exit code 1.

Here is my package.json:

{
  "name": "fireplace-admin",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@fireproof/core": "^0.19.111",
    "@fireproof/partykit": "^0.19.111",
    "@fortawesome/fontawesome-svg-core": "^6.6.0",
    "@fortawesome/free-solid-svg-icons": "^6.6.0",
    "@fortawesome/react-fontawesome": "^0.2.2",
    "@testing-library/jest-dom": "^5.17.0",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "@types/jest": "^27.5.2",
    "@types/node": "^16.18.119",
    "@types/react": "^18.3.12",
    "@types/react-dom": "^18.3.1",
    "partykit": "^0.0.111",
    "partysocket": "^1.0.2",
    "react": "^18.3.1",
    "react-dom": "^18.3.1",
    "react-router-dom": "^6.28.0",
    "react-scripts": "5.0.1",
    "typescript": "^4.9.5",
    "use-fireproof": "^0.19.111",
    "web-vitals": "^2.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

This was an app that worked previous using v0.18 and a different connector. I simply upgraded fireproof and switched connectors. I suspect that the partykit package is still doing something wrong.

Updated: I had failed to update use-fireproof, but I confirmed this was unrelated (still fails with same error)

mschoch commented 1 day ago

Additionally, while trying to upgrade the firehouse-chat application, I encounter the following similar issues that seem related to the package of the partykit gateway package.

❯ pnpm dev

> react-fireproof@0.0.0 dev /Users/mschoch/firehouse-chat
> partykit dev --live

🎈 PartyKit v0.0.85
--------------------
▲ [WARNING] Duplicate "className" attribute in JSX element [duplicate-object-key]

    src/client.tsx:41:46:
      41 │         <div className={styles.layoutSidebar} className={`${styles.layoutSidebar} ${isMobChannelsOpen ...
         ╵                                               ~~~~~~~~~

  The original "className" attribute is here:

    src/client.tsx:41:13:
      41 │         <div className={styles.layoutSidebar} className={`${styles.layoutSidebar} ${isMobChannelsOpen ...
         ╵              ~~~~~~~~~

▲ [WARNING] Duplicate "className" attribute in JSX element [duplicate-object-key]

    src/components/Message.tsx:53:28:
      53 │     <li className="message" className={styles.listItem}>
         ╵                             ~~~~~~~~~

  The original "className" attribute is here:

    src/components/Message.tsx:53:8:
      53 │     <li className="message" className={styles.listItem}>
         ╵         ~~~~~~~~~

✘ [ERROR] Could not resolve "node:fs/promises"

    node_modules/.pnpm/@fireproof+core@0.19.111_react@18.3.1_typescript@5.5.4/node_modules/@fireproof/core/node-filesystem-INX4ZTHE.js:10:27:
      10 │     this.fs = await import("node:fs/promises");
         ╵                            ~~~~~~~~~~~~~~~~~~

  The package "node:fs/promises" wasn't found on the file system but is built into node. Are you
  trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this
  error.

✘ [ERROR] Could not resolve "node:fs/promises"

    node_modules/.pnpm/use-fireproof@0.19.111_react@18.3.1_typescript@5.5.4/node_modules/use-fireproof/node-filesystem-DCI7OGPH.js:10:27:
      10 │     this.fs = await import("node:fs/promises");
         ╵                            ~~~~~~~~~~~~~~~~~~

  The package "node:fs/promises" wasn't found on the file system but is built into node. Are you
  trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this
  error.

✘ [ERROR] Could not resolve "path"

    node_modules/.pnpm/memfs@4.14.0/node_modules/memfs/lib/volume.js:8:27:
      8 │ const pathModule = require("path");
        ╵                            ~~~~~~

  The package "path" wasn't found on the file system but is built into node. Are you trying to
  bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

✘ [ERROR] Could not resolve "assert"

    node_modules/.pnpm/memfs@4.14.0/node_modules/memfs/lib/internal/errors.js:11:23:
      11 │ const assert = require("assert");
         ╵                        ~~~~~~~~

  The package "assert" wasn't found on the file system but is built into node. Are you trying to
  bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

✘ [ERROR] Could not resolve "util"

    node_modules/.pnpm/memfs@4.14.0/node_modules/memfs/lib/internal/errors.js:12:21:
      12 │ const util = require("util");
         ╵                      ~~~~~~

  The package "util" wasn't found on the file system but is built into node. Are you trying to
  bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

✘ [ERROR] Could not resolve "stream"

    node_modules/.pnpm/memfs@4.14.0/node_modules/memfs/lib/volume.js:17:25:
      17 │ const stream_1 = require("stream");
         ╵                          ~~~~~~~~

  The package "stream" wasn't found on the file system but is built into node. Are you trying to
  bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

✘ [ERROR] Could not resolve "events"

    node_modules/.pnpm/memfs@4.14.0/node_modules/memfs/lib/volume.js:19:25:
      19 │ const events_1 = require("events");
         ╵                          ~~~~~~~~

  The package "events" wasn't found on the file system but is built into node. Are you trying to
  bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

✘ [ERROR] Could not resolve "util"

    node_modules/.pnpm/memfs@4.14.0/node_modules/memfs/lib/volume.js:22:21:
      22 │ const util = require("util");
         ╵                      ~~~~~~

  The package "util" wasn't found on the file system but is built into node. Are you trying to
  bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

✘ [ERROR] Could not resolve "events"

    node_modules/.pnpm/memfs@4.14.0/node_modules/memfs/lib/node.js:7:25:
      7 │ const events_1 = require("events");
        ╵                          ~~~~~~~~

  The package "events" wasn't found on the file system but is built into node. Are you trying to
  bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

Error: Build failed with 9 errors:
node_modules/.pnpm/@fireproof+core@0.19.111_react@18.3.1_typescript@5.5.4/node_modules/@fireproof/core/node-filesystem-INX4ZTHE.js:10:27: ERROR: Could not resolve "node:fs/promises"
node_modules/.pnpm/memfs@4.14.0/node_modules/memfs/lib/internal/errors.js:11:23: ERROR: Could not resolve "assert"
node_modules/.pnpm/memfs@4.14.0/node_modules/memfs/lib/internal/errors.js:12:21: ERROR: Could not resolve "util"
node_modules/.pnpm/memfs@4.14.0/node_modules/memfs/lib/node.js:7:25: ERROR: Could not resolve "events"
node_modules/.pnpm/memfs@4.14.0/node_modules/memfs/lib/volume.js:8:27: ERROR: Could not resolve "path"
...
    at failureErrorWithLog (/Users/mschoch/firehouse-chat/node_modules/.pnpm/esbuild@0.20.0/node_modules/esbuild/lib/main.js:1651:15)
    at /Users/mschoch/firehouse-chat/node_modules/.pnpm/esbuild@0.20.0/node_modules/esbuild/lib/main.js:1059:25
    at /Users/mschoch/firehouse-chat/node_modules/.pnpm/esbuild@0.20.0/node_modules/esbuild/lib/main.js:1004:52
    at buildResponseToResult (/Users/mschoch/firehouse-chat/node_modules/.pnpm/esbuild@0.20.0/node_modules/esbuild/lib/main.js:1057:7)
    at /Users/mschoch/firehouse-chat/node_modules/.pnpm/esbuild@0.20.0/node_modules/esbuild/lib/main.js:1086:16
    at responseCallbacks.<computed> (/Users/mschoch/firehouse-chat/node_modules/.pnpm/esbuild@0.20.0/node_modules/esbuild/lib/main.js:704:9)
    at handleIncomingPacket (/Users/mschoch/firehouse-chat/node_modules/.pnpm/esbuild@0.20.0/node_modules/esbuild/lib/main.js:764:9)
    at Socket.readFromStdout (/Users/mschoch/firehouse-chat/node_modules/.pnpm/esbuild@0.20.0/node_modules/esbuild/lib/main.js:680:7)
    at Socket.emit (node:events:519:28)
    at addChunk (node:internal/streams/readable:559:12) {
  errors: [
    {
      detail: undefined,
      id: '',
      location: [Object],
      notes: [Array],
      pluginName: '',
      text: 'Could not resolve "node:fs/promises"'
    },
    {
      detail: undefined,
      id: '',
      location: [Object],
      notes: [Array],
      pluginName: '',
      text: 'Could not resolve "assert"'
    },
    {
      detail: undefined,
      id: '',
      location: [Object],
      notes: [Array],
      pluginName: '',
      text: 'Could not resolve "util"'
    },
    {
      detail: undefined,
      id: '',
      location: [Object],
      notes: [Array],
      pluginName: '',
      text: 'Could not resolve "events"'
    },
    {
      detail: undefined,
      id: '',
      location: [Object],
      notes: [Array],
      pluginName: '',
      text: 'Could not resolve "path"'
    },
    {
      detail: undefined,
      id: '',
      location: [Object],
      notes: [Array],
      pluginName: '',
      text: 'Could not resolve "stream"'
    },
    {
      detail: undefined,
      id: '',
      location: [Object],
      notes: [Array],
      pluginName: '',
      text: 'Could not resolve "events"'
    },
    {
      detail: undefined,
      id: '',
      location: [Object],
      notes: [Array],
      pluginName: '',
      text: 'Could not resolve "util"'
    },
    {
      detail: undefined,
      id: '',
      location: [Object],
      notes: [Array],
      pluginName: '',
      text: 'Could not resolve "node:fs/promises"'
    }
  ],
  warnings: [
    {
      detail: undefined,
      id: 'duplicate-object-key',
      location: [Object],
      notes: [Array],
      pluginName: '',
      text: 'Duplicate "className" attribute in JSX element'
    },
    {
      detail: undefined,
      id: 'duplicate-object-key',
      location: [Object],
      notes: [Array],
      pluginName: '',
      text: 'Duplicate "className" attribute in JSX element'
    }
  ]
}
Error: Build failed with 9 errors:
node_modules/.pnpm/@fireproof+core@0.19.111_react@18.3.1_typescript@5.5.4/node_modules/@fireproof/core/node-filesystem-INX4ZTHE.js:10:27: ERROR: Could not resolve "node:fs/promises"
node_modules/.pnpm/memfs@4.14.0/node_modules/memfs/lib/internal/errors.js:11:23: ERROR: Could not resolve "assert"
node_modules/.pnpm/memfs@4.14.0/node_modules/memfs/lib/internal/errors.js:12:21: ERROR: Could not resolve "util"
node_modules/.pnpm/memfs@4.14.0/node_modules/memfs/lib/node.js:7:25: ERROR: Could not resolve "events"
node_modules/.pnpm/memfs@4.14.0/node_modules/memfs/lib/volume.js:8:27: ERROR: Could not resolve "path"
...
    at failureErrorWithLog (/Users/mschoch/firehouse-chat/node_modules/.pnpm/esbuild@0.20.0/node_modules/esbuild/lib/main.js:1651:15)
    at /Users/mschoch/firehouse-chat/node_modules/.pnpm/esbuild@0.20.0/node_modules/esbuild/lib/main.js:1059:25
    at /Users/mschoch/firehouse-chat/node_modules/.pnpm/esbuild@0.20.0/node_modules/esbuild/lib/main.js:1004:52
    at buildResponseToResult (/Users/mschoch/firehouse-chat/node_modules/.pnpm/esbuild@0.20.0/node_modules/esbuild/lib/main.js:1057:7)
    at /Users/mschoch/firehouse-chat/node_modules/.pnpm/esbuild@0.20.0/node_modules/esbuild/lib/main.js:1086:16
    at responseCallbacks.<computed> (/Users/mschoch/firehouse-chat/node_modules/.pnpm/esbuild@0.20.0/node_modules/esbuild/lib/main.js:704:9)
    at handleIncomingPacket (/Users/mschoch/firehouse-chat/node_modules/.pnpm/esbuild@0.20.0/node_modules/esbuild/lib/main.js:764:9)
    at Socket.readFromStdout (/Users/mschoch/firehouse-chat/node_modules/.pnpm/esbuild@0.20.0/node_modules/esbuild/lib/main.js:680:7)
    at Socket.emit (node:events:519:28)
    at addChunk (node:internal/streams/readable:559:12) {
  errors: [
    {
      detail: undefined,
      id: '',
      location: [Object],
      notes: [Array],
      pluginName: '',
      text: 'Could not resolve "node:fs/promises"'
    },
    {
      detail: undefined,
      id: '',
      location: [Object],
      notes: [Array],
      pluginName: '',
      text: 'Could not resolve "assert"'
    },
    {
      detail: undefined,
      id: '',
      location: [Object],
      notes: [Array],
      pluginName: '',
      text: 'Could not resolve "util"'
    },
    {
      detail: undefined,
      id: '',
      location: [Object],
      notes: [Array],
      pluginName: '',
      text: 'Could not resolve "events"'
    },
    {
      detail: undefined,
      id: '',
      location: [Object],
      notes: [Array],
      pluginName: '',
      text: 'Could not resolve "path"'
    },
    {
      detail: undefined,
      id: '',
      location: [Object],
      notes: [Array],
      pluginName: '',
      text: 'Could not resolve "stream"'
    },
    {
      detail: undefined,
      id: '',
      location: [Object],
      notes: [Array],
      pluginName: '',
      text: 'Could not resolve "events"'
    },
    {
      detail: undefined,
      id: '',
      location: [Object],
      notes: [Array],
      pluginName: '',
      text: 'Could not resolve "util"'
    },
    {
      detail: undefined,
      id: '',
      location: [Object],
      notes: [Array],
      pluginName: '',
      text: 'Could not resolve "node:fs/promises"'
    }
  ],
  warnings: [
    {
      detail: undefined,
      id: 'duplicate-object-key',
      location: [Object],
      notes: [Array],
      pluginName: '',
      text: 'Duplicate "className" attribute in JSX element'
    },
    {
      detail: undefined,
      id: 'duplicate-object-key',
      location: [Object],
      notes: [Array],
      pluginName: '',
      text: 'Duplicate "className" attribute in JSX element'
    }
  ]
}

  ERROR Build failed with 9 errors:
       node_modules/.pnpm/@fireproof+core@0.19.111_react@18.3.1_typescript@5.5.4/node_modules/@fireproof/core/node-
       filesystem-INX4ZTHE.js:10:27: ERROR: Could not resolve "node:fs/promises"
       node_modules/.pnpm/memfs@4.14.0/node_modules/memfs/lib/internal/errors.js:11:23: ERROR: Could not resolve
       "assert"
       node_modules/.pnpm/memfs@4.14.0/node_modules/memfs/lib/internal/errors.js:12:21: ERROR: Could not resolve
       "util"
       node_modules/.pnpm/memfs@4.14.0/node_modules/memfs/lib/node.js:7:25: ERROR: Could not resolve "events"
       node_modules/.pnpm/memfs@4.14.0/node_modules/memfs/lib/volume.js:8:27: ERROR: Could not resolve "path"
       ...

 -node_modules/.pnpm/@fireproof+core@0.19.111_react@18.3.1_typescript@5.5.4/node_modules/@fireproof/core/node-files
  ystem-INX4ZTHE.js:10:27: ERROR: Could not resolve "node:fs/promises"
 -node_modules/.pnpm/memfs@4.14.0/node_modules/memfs/lib/internal/errors.js:11:23: ERROR: Could not resolve
  "assert"
 - node_modules/.pnpm/memfs@4.14.0/node_modules/memfs/lib/internal/errors.js:12:21: ERROR: Could not resolve "util"
 - node_modules/.pnpm/memfs@4.14.0/node_modules/memfs/lib/node.js:7:25: ERROR: Could not resolve "events"
 - node_modules/.pnpm/memfs@4.14.0/node_modules/memfs/lib/volume.js:8:27: ERROR: Could not resolve "path"
 - ...
 - failureErrorWithLog (node_modules/.pnpm/esbuild@0.20.0/node_modules/esbuild/lib/main.js:1651:15)
 -  (node_modules/.pnpm/esbuild@0.20.0/node_modules/esbuild/lib/main.js:1059:25)
 -  (node_modules/.pnpm/esbuild@0.20.0/node_modules/esbuild/lib/main.js:1004:52)
 - buildResponseToResult (node_modules/.pnpm/esbuild@0.20.0/node_modules/esbuild/lib/main.js:1057:7)
 -  (node_modules/.pnpm/esbuild@0.20.0/node_modules/esbuild/lib/main.js:1086:16)
 - responseCallbacks.<computed> (node_modules/.pnpm/esbuild@0.20.0/node_modules/esbuild/lib/main.js:704:9)
 - handleIncomingPacket (node_modules/.pnpm/esbuild@0.20.0/node_modules/esbuild/lib/main.js:764:9)
 - Socket.readFromStdout (node_modules/.pnpm/esbuild@0.20.0/node_modules/esbuild/lib/main.js:680:7)
 - Socket.emit (node:events:519:28)
 - addChunk (node:internal/streams/readable:559:12)