Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

109
Views
ParcelJS does not bundle imported js library

I have a simple NodeJS app (A Cloudflare Worker).

In the main typescript file (index.ts) I import the handler module which has this as the first line: const Monitor = import('ping-monitor')

ping-monitor is a dependency in package.json:

"dependencies": {
    "ping-monitor": "^0.6.2"
  }

Now when I run parcel build src/index.ts the output in the dist has: var $1ZQrD$pingmonitor = require("ping-monitor");

So the contents of ping-monitor are not bundled properly. And when I try to run this locally via wrangler dev (output is dist/worker.js) it complains: Uncaught ReferenceError: require is not defined.

How can I tell ParcelJS to bundle ping-monitor inside the output?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

By default, parcel won't bundle any dependencies for nodejs build targets. If you want to bundle all dependencies you can use the includeNodeModules option (see docs), like this:

{
   ...
   "main": "dist/worker.js",
   "targets" {
      "main": {
         "includeNodeModules": true
      }
   }
}

(You can also specify "whitelist" of modules to include).

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!