bun icon indicating copy to clipboard operation
bun copied to clipboard

Support Parcel

Open birkskyum opened this issue 10 months ago • 8 comments

What version of Bun is running?

0.7.4+78defe7a87226b5b10766e24fae458a62811dab2

What platform is your computer?

Darwin 22.5.0 arm64 arm

What steps can reproduce the bug?

Make an index.html file:

​<html>
  <head>
    <title>My First Parcel App</title>
  </head>
  <body>
    <h1>Hello, World!</h1>
  </body>
</html>

Run bun --bun x parcel index.html

What is the expected behavior?

➜ bun --bun x parcel index.html 
Server running at http://localhost:1234
✨ Built in 2ms

This is the case if --bun flag is removed

What do you see instead?


➜ bun --bun x parcel index.html
[bun] Warning: worker_threads.Worker option "execArgv" is not implemented.
dyld[63445]: missing symbol called
error: "parcel" exited with code 9 (SIGKILL)

Additional information

Related to

  • #4130
  • #4075

birkskyum avatar Aug 13 '23 16:08 birkskyum

Now I get:

➜ bun --bun x parcel index.html
3592 |         // $FlowFixMe
3593 |         (0, ($parcel$interopDefault($5VgCY$fs))).statSync = (filename)=>{
3594 |             return this.fs.statSync(filename);
3595 |         };
3596 |         try {
3597 |             m.load(filePath);
                   ^
TypeError: m.load is not a function. (In 'm.load(filePath)', 'm.load' is undefined)
      at load (/private/tmp/parcel@latest--bunx/node_modules/@parcel/package-manager/lib/index.js:3597:13)
      at processTicksAndRejections (:61:77)

17 |   try {
18 |     binding = require('./build/Release/watcher.node');
19 |   } catch (err) {
20 |     try {
21 |       binding = require('./build/Debug/watcher.node');
22 |     } catch (err) {
                                                                                                                                                                                                                                                                                                                                        ^
error: No prebuild or local build of @parcel/watcher found. Tried @parcel/watcher-darwin-arm64. Please ensure it is installed (don't use --no-optional when installing with npm). Otherwise it is possible we don't support your platform yet. If this is the case, please report an issue to https://github.com/parcel-bundler/watcher.
      at /private/tmp/parcel@latest--bunx/node_modules/@parcel/watcher/index.js:22:324
      at anonymous (native:1:1)
      at /private/tmp/parcel@latest--bunx/node_modules/@parcel/fs/lib/index.js:7:5
      at anonymous (native:1:1)
      at /private/tmp/parcel@latest--bunx/node_modules/@parcel/package-manager/lib/index.js:10:5
      at anonymous (native:1:1)
      at /private/tmp/parcel@latest--bunx/node_modules/@parcel/core/lib/worker.js:63:1
      at anonymous (native:1:1)
      at /private/tmp/parcel@latest--bunx/node_modules/@parcel/workers/lib/child.js:108:32
      at childInit (/private/tmp/parcel@latest--bunx/node_modules/@parcel/workers/lib/child.js:107:25)
17 |   try {
18 |     binding = require('./build/Release/watcher.node');
19 |   } catch (err) {
20 |     try {
21 |       binding = require('./build/Debug/watcher.node');
22 |     } catch (err) {

birkskyum avatar Jan 04 '24 14:01 birkskyum

@birkskyum I might be wrong and can't test it right now, but you may need to add @parcel/watcher to trustedDependencies in your package.json because only the top 500 packages get their postinstall scripts ran automatically and my guess is that it may not be on that list.

KTamas avatar Jan 04 '24 14:01 KTamas

@KTamas , thank you for the tip - I tried just now but I can't make it work.

birkskyum avatar Jan 04 '24 15:01 birkskyum

Any news on this? I cannot seem to make parcel work when installed with bun.

chdominguez avatar Feb 14 '24 15:02 chdominguez

Yeah I'm still waiting on it as well.

KTamas avatar Feb 14 '24 16:02 KTamas

The same problems with Bun v1.1.7 and Parcel bundler v2.12.0:

  • https://github.com/gowebly/gowebly/issues/71
  • https://github.com/parcel-bundler/parcel/issues/9707

🙏

koddr avatar May 08 '24 10:05 koddr

I hit similar trouble using bunx --bun parcel

It just looks like a napi feature hasn't been implemented yet. Perhaps someone might be able to point me in the right direction to get this working?

It's blocking me from using bun at work with parcel.

Edit: I meant to say "point me in the right direction to help contribute to this issue..."

Might be time to learn some zig?

jtenner avatar May 09 '24 13:05 jtenner

Also, I wanted to point out that @parcel/watch requires the use of detect-libc.

This wouldn't normally be a problem but...

> await import("detect-libc")
Object [Module] {
  GLIBC: 'glibc',
  MUSL: 'musl',
  default: {
    GLIBC: 'glibc',
    MUSL: 'musl',
    family: [Function: family],
    familySync: [Function: familySync],
    isNonGlibcLinux: [Function: isNonGlibcLinux],
    isNonGlibcLinuxSync: [Function: isNonGlibcLinuxSync],
    version: [Function: version],
    versionSync: [Function: versionSync]
  },
  family: [Function: family],
  familySync: [Function: familySync],
  isNonGlibcLinux: [Function: isNonGlibcLinux],
  isNonGlibcLinuxSync: [Function: isNonGlibcLinuxSync],
  version: [Function: version],
  versionSync: [Function: versionSync]
}

This actually looks fine, and uses a function to find the libc family. However, parcel uses the detect-libc package which doesn't expect family to be a function.

let name = `@parcel/watcher-${process.platform}-${process.arch}`;
if (process.platform === 'linux') {
  const { MUSL, family } = require('detect-libc');
  if (family === MUSL) {
    name += '-musl';
  } else {
    name += '-glibc';
  }
}

As you can see here, family is a function and will never equal MUSL, and thus, we get some issues.

We can solve this problem by calling await import("@parcel/watcher") instead of using import watcher from "@parcel/watcher", and I think this is unintended behavior.

jtenner avatar May 09 '24 14:05 jtenner