升级指南
¥Upgrade Guide
升级到新版本的 Turf 时,请查看 CHANGELOG 和 发行说明 以了解任何重大变更。如果你在升级后遇到错误,请查看 API 文档 在不同版本之间是否针对你的功能进行了更改,并进行相应的迁移。
¥When upgrading to a newer version of Turf, see the CHANGELOG and release notes for any breaking changes. If you are getting errors after upgrade, look to see if the API docs have changed for your functions between versions and migrate them as appropriate.
如何升级 Turf 取决于你的具体环境和工具。以下是一些入门指南。
¥How you upgrade Turf will depend on your specific environment and tooling. Here are some guidelines to get you started.
Turf 已发布版本的可信来源是 NPM。欢迎你使用重新发布这些软件包的其他提供商。
¥The source of truth for published versions of Turf is NPM. You are welcome to use other providers that republish these packages.
在 Node.js 中
¥In Node.js
# If you use the all-inclusive turf library
npm update --save @turf/turf
# if you use the smaller individual turf packages
npm update --save @turf/helpers @turf/buffer
作为 v7 版本包含 CommonJS 和 ESM 软件包。
¥As of v7, both CommonJS and ESM bundles are included.
在浏览器中
¥In browser
无论是本地下载,还是直接包含第三方版本的 Turf,都有多个 CDN 可供选择,每个 CDN 都有一个 URL 方案,允许你灵活地指定所需的版本。根据你的需求构建合适的 URL:
¥Whether downloading locally, or including a 3rd party version of turf directly, there are multiple CDN's to choose from and each has a URL scheme that allows you to specify what version you want, with some flexibility. Structure your URL as appropriate for your needs:
-
-
主版本中的最新版本:https://cdn.jsdelivr.net/npm/@turf/turf@7/turf.min.js
¥latest within major version: https://cdn.jsdelivr.net/npm/@turf/turf@7/turf.min.js
-
最新在次要版本中:https://cdn.jsdelivr.net/npm/@turf/turf@7.0/turf.min.js
¥latest within minor version: https://cdn.jsdelivr.net/npm/@turf/turf@7.0/turf.min.js
-
具体版本:https://cdn.jsdelivr.net/npm/@turf/turf@7.0.0/turf.min.js
¥specific version: https://cdn.jsdelivr.net/npm/@turf/turf@7.0.0/turf.min.js
-
-
主版本中的最新版本:https://unpkg.com/@turf/turf@^7/turf.min.js
¥latest within major version: https://unpkg.com/@turf/turf@^7/turf.min.js
-
最新在次要版本中:https://unpkg.com/@turf/turf@^7.0/turf.min.js
¥latest within minor version: https://unpkg.com/@turf/turf@^7.0/turf.min.js
-
具体版本:https://unpkg.com/@turf/turf@7.0.0/turf.min.js
¥specific version: https://unpkg.com/@turf/turf@7.0.0/turf.min.js
以下是从 Turf 6.x 迁移到 7.x 的示例。
¥Here's an example of migrating from Turf 6.x to 7.x
<script src="https://cdn.jsdelivr.net/npm/@turf/turf@6/turf.min.js"></script>
becomes
<script src="https://cdn.jsdelivr.net/npm/@turf/turf@7/turf.min.js"></script>
不建议使用始终提供 latest
最新版 Turf 的 CDN URL,尤其是在生产应用中。在主要版本之间,Turf 函数存在重大变更,这可能会导致你的应用处于崩溃状态。
¥It is not recommended to use a CDN URL that always gives you the latest
bleeding edge version of Turf, especially in a production app. There are breaking changes to turf functions between major versions that can leave your app in a broken state.