Skip to content

Commit

Permalink
docs: currentScript polyfill should be included in the final app, not…
Browse files Browse the repository at this point in the history
… the library itself
  • Loading branch information
haoqunjiang committed Oct 12, 2018
1 parent a83f8ff commit 7177097
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions docs/guide/build-targets.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ App is the default build target. In this mode:

## Library

::: tip Note on Vue Dependency
In lib mode, Vue is *externalized*. This means the bundle will not bundle Vue even if your code imports Vue. If the lib is used via a bundler, it will attempt to load Vue as a dependency through the bundler; otherwise, it falls back to a global `Vue` variable.
::: tip Note on IE Compatibility
In lib mode, the public path is [dynamically determined](https://github.com/vuejs/vue-cli/blob/dev/packages/@vue/cli-service/lib/commands/build/setPublicPath.js) based on the URL from which the main js file is loaded (to enable dynamic assets loading). However, this feature requires `document.currentScript` support, which is missing in IE. So it's recommended to include the [current-script-polyfill](https://www.npmjs.com/package/current-script-polyfill) in the final web page before the library is imported, if IE support is a requirement.
:::

::: tip Note on IE Compatibility
In lib mode, the public path is [dynamically determined](https://github.com/vuejs/vue-cli/blob/dev/packages/@vue/cli-service/lib/commands/build/setPublicPath.js) based on the URL from which the main js file is loaded (to enable dynamic assets loading). However, this feature requires `document.currentScript` support, which is missing in IE. So you need to manually import the [current-script-polyfill](https://www.npmjs.com/package/current-script-polyfill) in your library if IE support is a requirement.
::: tip Note on Vue Dependency
In lib mode, Vue is *externalized*. This means the bundle will not bundle Vue even if your code imports Vue. If the lib is used via a bundler, it will attempt to load Vue as a dependency through the bundler; otherwise, it falls back to a global `Vue` variable.
:::

You can build a single entry as a library using
Expand Down
8 changes: 4 additions & 4 deletions docs/zh/guide/build-targets.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@

##

::: tip 注意对 Vue 的依赖
在库模式中,Vue 是*外置的*。这意味着包中不会有 Vue,即便你在代码中导入了 Vue。如果这个库会通过一个打包器使用,它将尝试通过打包器以依赖的方式加载 Vue;否则就会回退到一个全局的 `Vue` 变量
::: tip 关于 IE 兼容性的提醒
在库模式中,项目的 `publicPath` 是根据主文件的加载路径[动态设置]((https://github.com/vuejs/vue-cli/blob/dev/packages/@vue/cli-service/lib/commands/build/setPublicPath.js))的(用以支持动态的资源加载能力)。但是这个功能用到了 `document.currentScript`,而 IE 浏览器并不支持这一特性。所以如果网站需要支持 IE 的话,建议使用库之前先在页面上引入 [current-script-polyfill](https://www.npmjs.com/package/current-script-polyfill)
:::

::: tip 关于 IE 兼容性的体型
在库模式中,项目的 `publicPath` 是根据主文件的加载路径[动态设置]((https://github.com/vuejs/vue-cli/blob/dev/packages/@vue/cli-service/lib/commands/build/setPublicPath.js))的(用以支持动态的资源加载能力)。但是这个功能用到了 `document.currentScript`,而 IE 浏览器并不支持这一特性。所以如果你的库需要支持 IE 的话,请自行在项目中引入 [current-script-polyfill](https://www.npmjs.com/package/current-script-polyfill)
::: tip 注意对 Vue 的依赖
在库模式中,Vue 是*外置的*。这意味着包中不会有 Vue,即便你在代码中导入了 Vue。如果这个库会通过一个打包器使用,它将尝试通过打包器以依赖的方式加载 Vue;否则就会回退到一个全局的 `Vue` 变量
:::


Expand Down

0 comments on commit 7177097

Please sign in to comment.