withastro/astro

如何解决该 bug ?

Closed this issue · 6 comments

Astro Info

Astro                    v5.0.1
Node                     v20.18.0
System                   macOS (x64)
Package Manager          yarn
Output                   static
Adapter                  none
Integrations             @astrojs/sitemap

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

JakiChen@macbook-pro-15 astro % npm i astro-svgs -D
npm error code ERESOLVE
npm error ERESOLVE unable to resolve dependency tree
npm error
npm error While resolving: astro@0.0.1
npm error Found: astro@5.0.1
npm error node_modules/astro
npm error astro@"^5.0.1" from the root project
npm error
npm error Could not resolve dependency:
npm error peer astro@"^4.0.0" from astro-svgs@1.1.3
npm error node_modules/astro-svgs
npm error dev astro-svgs@"*" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
npm error
npm error
npm error For a full report see:
npm error /Users/JakiChen/.npm/_logs/2024-12-03T15_01_43_571Z-eresolve-report.txt
npm error A complete log of this run can be found in: /Users/JakiChen/.npm/_logs/2024-12-03T15_01_43_571Z-debug-0.log
JakiChen@macbook-pro-15 astro %

移除该代码吗?

"peerDependencies": {
    "astro": "^4.0.0"
  }

倘若移除,似乎没法完成编译?

JakiChen@macbook-pro-15 svgs % npm run build   

> astro-svgs@1.2.0 build
> unbuild

ℹ Building astro-svgs                                                                                                                              22:59:02
ℹ Cleaning dist directory: ./dist                                                                                                                  22:59:02

[22:59:13]  ERROR  Error building /Users/JakiChen/Desktop/gh-5.0/integrations/svgs: SyntaxError: Unexpected token (1:7) in /Users/JakiChen/Desktop/gh-5.0/integrations/svgs/node_modules/astro/index.d.ts


 ERROR  Unexpected token (1:7) in /Users/JakiChen/Desktop/gh-5.0/integrations/svgs/node_modules/astro/index.d.ts                                    22:59:13

  at pp$4.raise (/Users/JakiChen/Desktop/gh-5.0/node_modules/rollup/dist/es/shared/node-entry.js:21621:13)
  at pp$9.unexpected (/Users/JakiChen/Desktop/gh-5.0/node_modules/rollup/dist/es/shared/node-entry.js:18829:8)
  at pp$9.expect (/Users/JakiChen/Desktop/gh-5.0/node_modules/rollup/dist/es/shared/node-entry.js:18823:26)
  at pp$8.parseExportSpecifiers (/Users/JakiChen/Desktop/gh-5.0/node_modules/rollup/dist/es/shared/node-entry.js:19878:8)
  at Parser.parseExport (/Users/JakiChen/Desktop/gh-5.0/node_modules/rollup/dist/es/shared/node-entry.js:26090:32)
  at pp$8.parseStatement (/Users/JakiChen/Desktop/gh-5.0/node_modules/rollup/dist/es/shared/node-entry.js:19005:74)
  at pp$8.parseTopLevel (/Users/JakiChen/Desktop/gh-5.0/node_modules/rollup/dist/es/shared/node-entry.js:18886:21)
  at Parser.parse (/Users/JakiChen/Desktop/gh-5.0/node_modules/rollup/dist/es/shared/node-entry.js:18658:15)
  at Function.parse (/Users/JakiChen/Desktop/gh-5.0/node_modules/rollup/dist/es/shared/node-entry.js:18708:35)
  at Graph.contextParse (/Users/JakiChen/Desktop/gh-5.0/node_modules/rollup/dist/es/shared/node-entry.js:25754:38) 



 ERROR  Unexpected token (1:7) in /Users/JakiChen/Desktop/gh-5.0/integrations/svgs/node_modules/astro/index.d.ts                                    22:59:13

npm error Lifecycle script `build` failed with error:
npm error code 1
npm error path /Users/JakiChen/Desktop/gh-5.0/integrations/svgs
npm error workspace astro-svgs@1.2.0
npm error location /Users/JakiChen/Desktop/gh-5.0/integrations/svgs
npm error command failed
npm error command sh -c unbuild
JakiChen@macbook-pro-15 svgs % 

What's the expected result?

有没有构建工具可以推荐,类似官方 @astrojs/sitemap 那样的,好像 5.0.1 中并未受到影响。

Is there any build tool you can recommend, similar to the official @astrojs/sitemap? It seems that this is not affected in 5.0.1.

Link to Minimal Reproducible Example

null

Participation

  • I am willing to submit a pull request for this issue.

Hello @JakiChen. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with needs repro will be closed if they have no activity within 3 days.

Astro 5 has experimental built-in support for SVGs, which may work better: https://docs.astro.build/en/reference/experimental-flags/svg/

Many thanks, @ascorbic,

I'm the maintainer of astro-svgs (svg sprites) and other plugin packages (similarly based on unbuild and "peerDependencies": {
"astro": "^4.0.0"
}) and I'm currently at a loss when facing the update of astro 5.0.0.

Heyyy, @ematipico

You can try npx astro add astro-svgs astro-robots astro-favicons in the astro5.0.1 project or install it manually, and you can reproduce the problem I encountered. I am not sure whether to remove "peerDependencies": {
"astro": "^4.0.0"
} and do more configuration to solve the problem, or whether there is a better build tool for plugin packaging. Thank you very much.

Hi @JakiChen would love your feedback on the experimental SVGs implementation and the Stage 3 withastro/roadmap#1035 RFC

Dear, All

@ematipico

Since I've used injectTypes to automatically generate virtual module definitions to support SymbolId's smart hints, I've made some tweaks and it seems to be able to install normally via npx astro add astro-svgs.

 "peerDependencies": {
    "astro": "^4.14.0 || ^5.0.0"
  }

@stramel

But I found that the new version of Astro5+ does not seem to have @astrojs/check installed by default, I expect the official to add back a better solution?

astro check && astro build is very friendly to my astro-svgs plugin, able to detect if the icon is misspelled or missing, or invalid.

Hey, @stramel

I haven't experienced the magic of SVGs yet, and personally, I probably don't like importing SVG files over and over again.

I'm more focused on the way I deal with astro-svg now, and with the help of the open component API, it is beneficial for me to build components such as buttons, for example, buttons may have many styles, and there will be many different icons, and all we need to do is pass a SymbolId to quickly get what we need.

Of course, astro-svg has a lot of drawbacks, such as that it won't be excluded if it's not used on all pages (because it's a sprite.svg built from valid svg files in the base and subdirectories)

GdMqMqEXMAAVVdP