theme-shoka-x / hexo-theme-shokaX

a hexo theme based on shoka
https://docs-hexo.shokax.top
GNU Affero General Public License v3.0
320 stars 43 forks source link

兼容algolia v5 #347

Closed kuiyr0810 closed 1 month ago

kuiyr0810 commented 1 month ago

在开始之前......

问题发生位置

其他问题

问题描述

X [ERROR] Could not resolve "algoliasearch/dist/algoliasearch-lite.esm.browser.js" (originally "algoliasearch/lite")

node_modules/hexo-theme-shokax/source/js/_app/page/search.ts:7:26:
  7 │ import algoliasearch from 'algoliasearch/lite'
    ╵                           ~~~~~~~~~~~~~~~~~~~~

The path "./dist/algoliasearch-lite.esm.browser.js" is not exported by package "algoliasearch":

node_modules/algoliasearch/package.json:18:13:
  18 │   "exports": {
     ╵              ^

The path "algoliasearch/lite" was remapped to "algoliasearch/dist/algoliasearch-lite.esm.browser.js" using the alias feature, which then couldn't be resolved. Keep in mind that import path aliases are resolved in the current working directory.

You can mark the path "algoliasearch/dist/algoliasearch-lite.esm.browser.js" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle.

FATAL Something's wrong. Maybe you can find the solution here: https://hexo.io/docs/troubleshooting.html Error: Build failed with 1 error: node_modules/hexo-theme-shokax/source/js/_app/page/search.ts:7:26: ERROR: Could not resolve "algoliasearch/dist/algoliasearch-lite.esm.browser.js" (originally "algoliasearch/lite") at failureErrorWithLog (D:\blog\node_modules\esbuild\lib\main.js:1476:15) at D:\blog\node_modules\esbuild\lib\main.js:945:25 at D:\blog\node_modules\esbuild\lib\main.js:897:52 at buildResponseToResult (D:\blog\node_modules\esbuild\lib\main.js:943:7) at D:\blog\node_modules\esbuild\lib\main.js:970:16 at responseCallbacks. (D:\blog\node_modules\esbuild\lib\main.js:622:9) at handleIncomingPacket (D:\blog\node_modules\esbuild\lib\main.js:677:12) at Socket.readFromStdout (D:\blog\node_modules\esbuild\lib\main.js:600:7) at Socket.emit (node:events:519:28) at addChunk (node:internal/streams/readable:559:12)

复现步骤

更新了package.json中的所有

相关配置

No response

注意事项

kuiyr0810 commented 1 month ago

已解决,algoliasearch版本问题,降级即可

zkz098 commented 1 month ago

搜索跨大版本升级兼容性问题,修复前保持开启

zkz098 commented 1 month ago

cc @D-Sketon @FidStyle 测一下 https://github.com/theme-shoka-x/hexo-theme-shokaX/commit/1b4ee209e5befe5b9a3d921724fbc5383003234f 改完的版本搜索能不能正常使用 我这边打包一直在引入algoliaseach@4的js,怀疑打包环境被污染了

D-Sketon commented 1 month ago

没有问题