edemaine / solid-meteor-data

Integrating SolidJS and Meteor reactivity
MIT License
16 stars 2 forks source link

Could not resolve "meteor/meteor" #9

Open Strdate opened 1 year ago

Strdate commented 1 year ago

After adding this package, the application fails to build with following errors. Do you have any idea why it could happen?

X [ERROR] Could not resolve "meteor/tracker"

    node_modules/solid-meteor-data/autoTracker.ts:1:22:
      1 │ import {Tracker} from 'meteor/tracker';
        ╵                       ~~~~~~~~~~~~~~~~

  You can mark the path "meteor/tracker" as external to exclude it from the bundle, which will remove this error.

X [ERROR] Could not resolve "meteor/meteor"

    node_modules/solid-meteor-data/createFind.ts:1:21:
      1 │ import {Meteor} from 'meteor/meteor';
        ╵                      ~~~~~~~~~~~~~~~

  You can mark the path "meteor/meteor" as external to exclude it from the bundle, which will remove this error.

X [ERROR] Could not resolve "meteor/meteor"

    node_modules/solid-meteor-data/createSubscribe.ts:1:21:
      1 │ import {Meteor} from 'meteor/meteor';
        ╵                      ~~~~~~~~~~~~~~~

  You can mark the path "meteor/meteor" as external to exclude it from the bundle, which will remove this error.

X [ERROR] Could not resolve "meteor/tracker"

    node_modules/solid-meteor-data/createTracker.ts:1:22:
      1 │ import {Tracker} from 'meteor/tracker';
        ╵                       ~~~~~~~~~~~~~~~~

  You can mark the path "meteor/tracker" as external to exclude it from the bundle, which will remove this error.

X [ERROR] Could not resolve "meteor/meteor"

    node_modules/solid-meteor-data/createFindOne.ts:1:21:
      1 │ import {Meteor} from 'meteor/meteor';
        ╵                      ~~~~~~~~~~~~~~~

  You can mark the path "meteor/meteor" as external to exclude it from the bundle, which will remove this error.

X [ERROR] Could not resolve "meteor/mongo"

    node_modules/solid-meteor-data/createFind.ts:2:20:
      2 │ import {Mongo} from 'meteor/mongo';
        ╵                     ~~~~~~~~~~~~~~

  You can mark the path "meteor/mongo" as external to exclude it from the bundle, which will remove this error.

X [ERROR] Could not resolve "meteor/tracker"

    node_modules/solid-meteor-data/createFind.ts:3:22:
      3 │ import {Tracker} from 'meteor/tracker';
        ╵                       ~~~~~~~~~~~~~~~~

  You can mark the path "meteor/tracker" as external to exclude it from the bundle, which will remove this error.

22:33:19 [vite] error while updating dependencies:
Error: Build failed with 7 errors:
node_modules/solid-meteor-data/autoTracker.ts:1:22: ERROR: Could not resolve "meteor/tracker"
node_modules/solid-meteor-data/createFind.ts:1:21: ERROR: Could not resolve "meteor/meteor"
node_modules/solid-meteor-data/createFind.ts:2:20: ERROR: Could not resolve "meteor/mongo"
node_modules/solid-meteor-data/createFind.ts:3:22: ERROR: Could not resolve "meteor/tracker"
node_modules/solid-meteor-data/createFindOne.ts:1:21: ERROR: Could not resolve "meteor/meteor"
...
    at failureErrorWithLog (C:\Users\Adam\source\repos\maso-solid\node_modules\esbuild\lib\main.js:1566:15)
    at C:\Users\Adam\source\repos\maso-solid\node_modules\esbuild\lib\main.js:1024:28
    at runOnEndCallbacks (C:\Users\Adam\source\repos\maso-solid\node_modules\esbuild\lib\main.js:1438:61)
    at buildResponseToResult (C:\Users\Adam\source\repos\maso-solid\node_modules\esbuild\lib\main.js:1022:7)
    at C:\Users\Adam\source\repos\maso-solid\node_modules\esbuild\lib\main.js:1134:14
    at responseCallbacks.<computed> (C:\Users\Adam\source\repos\maso-solid\node_modules\esbuild\lib\main.js:671:9)
    at handleIncomingPacket (C:\Users\Adam\source\repos\maso-solid\node_modules\esbuild\lib\main.js:726:9)
    at Socket.readFromStdout (C:\Users\Adam\source\repos\maso-solid\node_modules\esbuild\lib\main.js:647:7)
    at Socket.emit (events.js:400:28)
    at addChunk (internal/streams/readable.js:293:12)
    at readableAddChunk (internal/streams/readable.js:267:9)
    at Socket.Readable.push (internal/streams/readable.js:206:10)
    at Pipe.onStreamRead (internal/stream_base_commons.js:188:23)

Meteor packages file:

meteor-base@1.5.1             # Packages every Meteor app needs to have
mobile-experience@1.1.0       # Packages for a great mobile UX
mongo                   # The database Meteor supports right now
reactive-var@1.0.12            # Reactive variable for tracker

standard-minifier-css@1.8.2   # CSS minifier run for production mode
standard-minifier-js@2.8.1    # JS minifier run for production mode
es5-shim@4.8.0                # ECMAScript 5 compatibility for older browsers
ecmascript@0.16.3              # Enable ECMAScript2015+ syntax in app code
typescript              # Enable TypeScript syntax in .ts and .tsx modules
shell-server@0.5.0            # Server-side component of the `meteor shell` command
hot-module-replacement@0.5.2  # Update client in development without reloading the page

static-html@1.3.2             # Define static page content in .html files
vite:bundler
mdg:validated-method
accounts-base
accounts-password

package.json:

{
  "name": "maso-solid",
  "private": true,
  "scripts": {
    "start": "meteor run",
    "test": "meteor test --once --driver-package meteortesting:mocha",
    "test-app": "TEST_WATCH=1 meteor test --full-app --driver-package meteortesting:mocha",
    "visualize": "meteor --production --extra-packages bundle-visualizer"
  },
  "dependencies": {
    "@babel/runtime": "^7.17.9",
    "@solidjs/router": "^0.5.1",
    "@suid/icons-material": "^0.5.0",
    "@suid/material": "^0.7.0",
    "@suid/vite-plugin": "^0.1.0",
    "@types/meteor-mdg-validated-method": "^1.2.5",
    "meteor-node-stubs": "^1.2.1",
    "simpl-schema": "^3.0.1",
    "solid-js": "^1.5.4",
    "solid-meteor-data": "^0.6.2",
    "solid-styled-components": "^0.28.5"
  },
  "meteor": {
    "mainModule": {
      "client": "client/main.tsx",
      "server": "server/main.ts"
    },
    "testModule": "tests/main.ts"
  },
  "devDependencies": {
    "@types/jest": "^29.2.3",
    "@types/meteor": "^1.4.87",
    "babel-preset-solid": "^1.5.4",
    "typescript": "^4.6.3",
    "vite": "^3.0.9",
    "vite-plugin-solid": "^2.3.0",
    "vite-plugin-solid-svg": "^0.4.1"
  }
}
edemaine commented 1 year ago

I've not used the new Meteor Vite integration. My guess is it's that. Is there a different way to import Meteor packages in Vite?

Strdate commented 1 year ago

Thanks for your answer. Unfortunately I have no idea. I'm struggling to understand how Vite even works.

Strdate commented 1 year ago

I made it work by editing vite.config.js and excluding the dependencies:

import { defineConfig } from 'vite';
import solidPlugin from 'vite-plugin-solid';
import solidSvg from "vite-plugin-solid-svg";

export default defineConfig({
  plugins: [solidPlugin(), solidSvg({
    defaultExport: 'component',
  })],
  meteor: {
    clientEntry: 'imports/ui/main.jsx',
  },
  optimizeDeps: {
    exclude: [
      'meteor/tracker',
      'meteor/meteor',
      'meteor/mongo'
    ],
  }
});