fix: $slidev injection, close #679 #683
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
修复 #679
问题原因:
Symbol
惹的祸全局属性
$slidev
的注入名声明在packages/client/constants.ts
,为Symbol
,其提供于文件packages/client/modules/context.ts
,注入于插件slidev:layout-transform:pre
slidev:context-transform:pre
。开发环境下,上述两插件中的依赖项会预编译到
node_modules/.vite/deps
,即,constants.ts
暂存位置。提供处仍引用的是packages/client/constants.ts
。此时出现了两份
constants.ts
,而 Symbol('slidev-slidev-context') !== Symbol('slidev-slidev-context'),故而报错。解决办法:
分别配置两插件,在预构建中强制排除依赖项
@slidev/client/constants
。