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

Issue with astro add and @astrojs/mdx #5459

Closed
1 task
Lofty-Brambles opened this issue Nov 23, 2022 · 4 comments · Fixed by #5778
Closed
1 task

Issue with astro add and @astrojs/mdx #5459

Lofty-Brambles opened this issue Nov 23, 2022 · 4 comments · Fixed by #5778
Assignees
Labels
- P3: minor bug An edge case that only affects very specific usage (priority)

Comments

@Lofty-Brambles
Copy link

What version of astro are you using?

1.6.10

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

pnpm

What operating system are you using?

Windows [WSL]

Describe the Bug

The addition of Preact leads to an error:

hp@DESKTOP-H1T4LNI MINGW64 ~/My Repositories/personal/peppered-pen (main)
$ pnpm astro add preact

> @example/basics@0.0.1 astro C:\Users\hp\My Repositories\personal\peppered-pen
> astro "add" "preact"

⠋ Resolving packages...(node:9628) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
✔ Resolving packages...

  Astro will run the following command:
  If you skip this step, you can always run it yourself later

 ╭──────────────────────────────────────────╮
 │ pnpm add @astrojs/preact preact@^10.6.5  │
 ╰──────────────────────────────────────────╯

√ Continue? ... yes
✔ Installing dependencies...
 error   Failed to resolve entry for package "estree-walker". The package may have incorrect main/module/exports specified in its package.json: No known conditions for "." entry in "estree-walker" package    
  File:
    C:\Users\hp\My Repositories\personal\peppered-pen\node_modules\.pnpm\vite@3.2.4\node_modules\vite\dist\node\chunks\dep-67e7f8ab.js:34100:11
  Code:
      34099 | function packageEntryFailure(id, details) {
    > 34100 |     throw new Error(`Failed to resolve entry for package "${id}". ` +
            |           ^
      34101 |         `The package may have incorrect main/module/exports specified in its package.json` +
      34102 |         (details ? ': ' + details : '.'));
      34103 | }

  Stacktrace:
Error: Failed to resolve entry for package "estree-walker". The package may have incorrect main/module/exports specified in its package.json: No known conditions for "." entry in "estree-walker" package      
    at packageEntryFailure (file:///C:/Users/hp/My%20Repositories/personal/peppered-pen/node_modules/.pnpm/vite@3.2.4/node_modules/vite/dist/node/chunks/dep-67e7f8ab.js:34100:11)
    at resolvePackageEntry (file:///C:/Users/hp/My%20Repositories/personal/peppered-pen/node_modules/.pnpm/vite@3.2.4/node_modules/vite/dist/node/chunks/dep-67e7f8ab.js:34095:9)
    at tryNodeResolve (file:///C:/Users/hp/My%20Repositories/personal/peppered-pen/node_modules/.pnpm/vite@3.2.4/node_modules/vite/dist/node/chunks/dep-67e7f8ab.js:33838:20)
    at viteResolve (file:///C:/Users/hp/My%20Repositories/personal/peppered-pen/node_modules/.pnpm/vite@3.2.4/node_modules/vite/dist/node/chunks/dep-67e7f8ab.js:53085:26)
    at Function._resolveFilename (file:///C:/Users/hp/My%20Repositories/personal/peppered-pen/node_modules/.pnpm/vite@3.2.4/node_modules/vite/dist/node/chunks/dep-67e7f8ab.js:53105:32)
    at Module._load (node:internal/modules/cjs/loader:841:27)
    at Module.require (node:internal/modules/cjs/loader:1061:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (C:\Users\hp\My Repositories\personal\peppered-pen\node_modules\.pnpm\estree-util-build-jsx@2.2.0\node_modules\estree-util-build-jsx\lib\index.js:23:28)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)

 ELIFECYCLE  Command failed with exit code 1.

Not sure how to replicate this in stackblitz.

Link to Minimal Reproducible Example

Participation

  • I am willing to submit a pull request for this issue.
@bluwy
Copy link
Member

bluwy commented Nov 24, 2022

It's working fine for me on macos. It seems a bit related to #5431 which should be fixed in the latest Astro version. We'd need a reproduction to further investigate this as I think this isn't OS specific, but maybe an existing import in your astro config is messing with it.

@bluwy bluwy added the needs response Issue needs response from OP label Nov 24, 2022
@Lofty-Brambles
Copy link
Author

Sure thing, I'm also adding the same issue from a discord forum post here.
I have added a recreation of the issue in a repository, whose link I've sent there too. Updating all the packages to the latest versions don't help. I'm on Windows [WSL] myself.

From trying to narrow it down, the issue may not be with astro... the estree-walker package seems to be used by rollup and/or @mdx-js/mdx, and there was a similar-ish issue somewhere here? I've got no idea as to what to do to fix it though. @bluwy

@bluwy bluwy removed the needs response Issue needs response from OP label Nov 28, 2022
@bluwy
Copy link
Member

bluwy commented Nov 28, 2022

I can reproduce this too. Some logging showed that it came from /Users/bjorn/Work/repros/test-astro/node_modules/.pnpm/estree-util-build-jsx@2.2.0/node_modules/estree-util-build-jsx/lib/index.js, so it's likely the @astrojs/mdx causing it.

I made a fix in Vite awhile ago at vitejs/vite#10593 but seems like the bug still happens. (That also reminds me to remove the Vite hack)

Anyways I think this can still be fixed by refactoring this part to only find the config file path, and not load the config file unnecessarily. Currently it tries to load and fail with the error.

@bluwy bluwy added the - P3: minor bug An edge case that only affects very specific usage (priority) label Nov 28, 2022
@Lofty-Brambles
Copy link
Author

Any updates on it/anything I can do? I encountered this same issue in another project and it seems like I cannot work without it getting resolved.

@natemoo-re natemoo-re changed the title Issue with create-astro Issue with astro add and @astrojs/mdx Dec 21, 2022
@bluwy bluwy self-assigned this Jan 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P3: minor bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants