meteor / meteor/meteor

v3.3 - server side package seems to be bundled for client

Open
#13,807 15 comments 0 reactions 0 assignees View on GitHub
idle modern-build-stack needs-reproduction
Dominant language
JavaScript
Stars
44.8k
Forks
5.2k
Avg merge
3d 12h
Merged PRs (30d)
25

Description

So just wanted to give `v3.3` a first go, but running into issues!

There definitely seems to be a bundling issue, when importing our own packages (inside a yarn monorepo!) on the server side of things.

We have our own package `@orderlion/bull-queue`, that essentially just gives us all kinds of helper functions and our setup to use [bullmq](https://bullmq.io/).

Its `package.json` looks like this:

```json
{
"name": "@orderlion/bull-queue",
"version": "3.1.0",
"main": "src/index.js",
"license": "MIT",
"private": true,
"type": "module",
"dependencies": {
"@orderlion/db": "*",
"@orderlion/helpers": "*",
"bullmq": "^5.45.2",
"ioredis": "5.6.0",
"lodash": "^4.17.21",
"meteor-random": "^0.0.3"
}
}
```

Very simple and absolutely no issues with the old bundler.
But with the new one, we get this error during startup:

```
Unable to resolve some modules:

"worker_threads" in /Users/patrick/dev/orderlion/orderlion_react/app/node_modules/bullmq/dist/esm/classes/child.js (web.browser)

If you notice problems related to these missing modules, consider running:

meteor npm install --save meteor-node-stubs
```

(yes, of course we have `meteor-node-stubs@1.2.19` installed!)

(Sidenote: if we then open localhost:3000 after this startup, we get this error on the client: `modules-runtime.js - Uncaught Error: Cannot find module 'crypto' at makeMissingError ...`)

Same issue with another package (`@orderlion/base`). Some of its files are NOT meant to be imported on the clientside (and of course they are not!). But for the server side, this package uses `cheerio` - which does not work on clientside. But if we leave cheerio in there, we get the same error:

```
Unable to resolve some modules:

"diagnostics_channel" in /Users/patrick/dev/orderlion/orderlion_react/app/node_modules/undici/lib/core/diagnostics.js (web.browser)
"perf_hooks" in /Users/patrick/dev/orderlion/orderlion_react/app/node_modules/undici/lib/web/fetch/util.js (web.browser)
"util/types" in /Users/patrick/dev/orderlion/orderlion_react/app/node_modules/undici/lib/web/fetch/util.js (web.browser)
"http2" in /Users/patrick/dev/orderlion/orderlion_react/app/node_modules/undici/lib/dispatcher/client-h2.js (web.browser)
"async_hooks" in /Users/patrick/dev/orderlion/orderlion_react/app/node_modules/undici/lib/api/api-request.js (web.browser)

If you notice problems related to these missing modules, consider running:

meteor npm install --save meteor-node-stubs
```

I checked in our `yarn.lock`- the `undici` package definitely comes from `cheerio` - which is definitely correct as the above errors disappeared after removing cheerio.

Can anyone help? ✌

Thanks, best Patrick

Contributor guide

Open the contributing guide

Research direction

Reproduce the v3.3 startup failure with the reported Yarn monorepo packages, first checking the client bundle path for @orderlion/bull-queue and its bullmq dependency. Compare that with the @orderlion/base and cheerio case, and verify done when server-only dependencies such as worker_threads, crypto, and undici's Node modules are no longer bundled for web.browser.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
build-system, full-stack
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.