fix(plugin-html): prevent errors arising from undeclared dependencies #13552
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.
这个 PR 做了什么? (简要描述所做更改)
With the latest stable release of Taro (v3.6.2), I ran into the following error when building with Yarn (v3.4.1):
This is caused by the
@tarojs/plugin-html
not declaring all required dependencies in itspackage.json
. Since the@babel/*
packages are required not only for developing/building the plugin, but also at run time (i.e. when the plugin is used), they should be specified asdependencies
rather thandevDependencies
.taro/packages/taro-plugin-html/src/index.ts
Lines 1 to 6 in 4b17fae
In the past, you could get away with it because installed packages are hoisted to the root of
node_modules
(a behaviour introduced by npm v3). However, phantom dependencies are known to be unsafe and has long been frowned upon. Moreover, these days, we can no longer rely on hoisting being in place, especially when newer package managers offer ways to explicitly guard against these violations (e.g. npm'sinstall-strategy
, Yarn's Plug'n'Play and pnpm'shoist=false
).这个 PR 是什么类型? (至少选择一个)
这个 PR 涉及以下平台: