Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange parseTree from 'jsonc-parser' error ('jsonc-parser' is a CommonJS module, which may not support all module.exports as named exports.) #1111

Closed
Zer0xxxx opened this issue Jun 24, 2024 · 12 comments

Comments

@Zer0xxxx
Copy link

Zer0xxxx commented Jun 24, 2024

When I start my Docker container, I get this error:

file:///root/.bun/install/global/node_modules/wireit/lib/util/ast.js:7
import { parseTree as parseTreeInternal } from 'jsonc-parser';
         ^^^^^^^^^
SyntaxError: Named export 'parseTree' not found. The requested module 'jsonc-parser' is a CommonJS module, which may not support all module.exports as named exports.

I've only noticed it today, it worked properly some days ago.

I'm using:

  • Bun v1.1.15
  • Dockerfile based on ubuntu:24.04
  • Wireit v0.14.4

wireit is globally installed with my Dockerfile, using: bun i -g wireit
(Also tried bun i -g [email protected], didn't change the result.)

@rschaufler
Copy link

i am encountering this issue too. It seems to be related to a resent update of the jsonc-parser package, specifically this commit where an export section was added to the package.json: microsoft/node-jsonc-parser@4f3cf98

@Zer0xxxx
Copy link
Author

i am encountering this issue too. It seems to be related to a resent update of the jsonc-parser package, specifically this commit where an export section was added to the package.json: microsoft/node-jsonc-parser@4f3cf98

Excellent! Happy to hear I'm not alone.

@rschaufler
Copy link

@Zer0xxxx you can workaround this issue by locking jsonc-parser to version 3.2.1 in your project until a fix is released.

@Zer0xxxx
Copy link
Author

Zer0xxxx commented Jun 24, 2024

@Zer0xxxx you can workaround this issue by locking jsonc-parser to version 3.2.1 in your project until a fix is released.

Yep!
I'm trying to do it like this right now, haven't tested it yet:

  "resolutions": {
    "jsonc-parser": "3.2.1"
  },

@rschaufler
Copy link

for any pnpm user, it works by putting the following section into your package.json:

  "pnpm": {
    "overrides": {
      "jsonc-parser": "~3.2.1"
    }
  }

@Zer0xxxx
Copy link
Author

for any pnpm user, it works by putting the following section into your package.json:

  "pnpm": {
    "overrides": {
      "jsonc-parser": "~3.2.1"
    }
  }

Lmao, this is also what is intended to work with Bun, but since I'm globally installing wireit in my Docker container, it seems like I'm doomed. Gonna investigate.

@Zer0xxxx
Copy link
Author

Zer0xxxx commented Jun 24, 2024

Installed wireit as a dependency in my package.json (and NOT as a dev dependency since I'm using bun install --production). Used the same overrides section, and now it's working again.

Looking forward to see it properly patched.

@Zer0xxxx
Copy link
Author

Heya @rschaufler
This seems to be fixed microsoft/node-jsonc-parser#91

Also, even if it wasn't totally from the Wireit side, maybe wireit should be more strict on its dependencies?

@rictic
Copy link
Member

rictic commented Jun 24, 2024

Locking in deps to specific versions has pros and cons. We miss bug fixes, and a using package can lose out on opportunities to deduplicate common deps.

The strategy of installing wireit in each monorepo or package root that uses wireit and using a lockfile would have prevented this breakage, and is a good practice overall IMO.

@rschaufler
Copy link

rschaufler commented Jun 25, 2024

@rictic i am working in a Monorepo with a lockfile. It however doesn't prevent the breakage because the dependency will be updated if you run a update on your packages to apply patch and minor updates. So in essence, the core issue here is that the recent minor update of node-jsonrc-parser was not backwards compatible as a minor update should be. However, the issue is now fixed thanks to @Zer0xxxx issue report at node-jsonc-parser.

@Zer0xxxx
Copy link
Author

Zer0xxxx commented Jun 25, 2024

@rictic i am working in a Monorepo with a lockfile. It however doesn't prevent the breakage because the dependency will be updated if you run a update on your packages to apply patch and minor updates. So in essence, the core issue here is that the recent minor update of node-jsonrc-parser was not backwards compatible as a minor update should be. However, the issue is now fixed thanks to @Zer0xxxx issue report at node-jsonc-parser.

Yeah. Indeed, it broke when I rebuilt from zero my container.
Considering it like a SemVer issue from jsonc-parser seems wise to me.

I understand your points of view, and I'm also happy that everything came back to normal so fast.
I will also scope a bit more my wireit install process in my container.

Thank you everyone.

Maybe we can close this issue, then?

@rictic
Copy link
Member

rictic commented Jun 25, 2024

Yep, closing as fixed. Thanks for filing this upstream!

@rictic rictic closed this as completed Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants