Skip to content

fix: esm package traversal#312

Merged
zbirenbaum merged 1 commit intozbirenbaum:masterfrom
Hacksore:fix/esm-package-traversal
Sep 10, 2024
Merged

fix: esm package traversal#312
zbirenbaum merged 1 commit intozbirenbaum:masterfrom
Hacksore:fix/esm-package-traversal

Conversation

@Hacksore
Copy link
Copy Markdown
Contributor

@Hacksore Hacksore commented Aug 29, 2024

Closes #306

I tested this by:

  1. creating a package.json in my home dir
  2. adding "type": "module"
  3. opening nvim and see copilot crash
  4. adding the package.json see in the diff to ~/.local/share/nvim/lazy/copilot.lua/copilot/package.json
  5. open nvim
  6. observed no crashes 🥳

when attempting to load the copilot nodejs will attempt to traverse
upwards to find a package.json to determin if it should run in ESM or
CJS mode.

if it finds one that contains `"type": "module"` it will crash copilot
because ESM handles various things different and the copilot impl is
CJS.

the solution here is to place a package.json file to prevent node from
traversing upwards.
@Hacksore
Copy link
Copy Markdown
Contributor Author

also linking this issue from node for others trying to fix this in their apps.
nodejs/node#54632

@Hacksore
Copy link
Copy Markdown
Contributor Author

can any devs in the chat take a look when they get some free time?

@MunifTanjim @zbirenbaum @mvaldes14

@zbirenbaum
Copy link
Copy Markdown
Owner

Thanks for researching this! LGTM

@zbirenbaum zbirenbaum merged commit f9e2c14 into zbirenbaum:master Sep 10, 2024
@Hacksore Hacksore deleted the fix/esm-package-traversal branch September 10, 2024 21:59
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

Successfully merging this pull request may close these issues.

ESM package.json in home directory crashes LSP

2 participants