Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(build): support @rollup/plugin-auto-install #1512

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/config/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ export default ({ command, mode }) => {
The polyfill is auto injected into the proxy module of each `index.html` entry. If the build is configured to use a non-html custom entry via `build.rollupOptions.input`, then it is necessary to manually import the polyfill in your custom entry:

```js
import 'vite/dynamic-import-polyfill'
import '/vite/dynamic-import-polyfill'
```

Note: the polyfill does **not** apply to [Library Mode](/guide/build#library-mode). If you need to support browsers without native dynamic import, you should probably avoid using it in your library.
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/backend-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ If you want to serve the HTML using a traditional backend (e.g. Rails, Laravel)

```js
// add the beginning of your app entry
import 'vite/dynamic-import-polyfill'
import '/vite/dynamic-import-polyfill'
```

2. For development, inject the following in your server's HTML template (substitute `http://localhost:3000` with the local URL Vite is running at):
Expand Down
7 changes: 6 additions & 1 deletion packages/vite/src/node/plugins/dynamicImportPolyfill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ResolvedConfig } from '..'
import { Plugin } from '../plugin'
import { isModernFlag } from './importAnaysisBuild'

export const polyfillId = 'vite/dynamic-import-polyfill'
export const polyfillId = '/vite/dynamic-import-polyfill'

export function dynamicImportPolyfillPlugin(config: ResolvedConfig): Plugin {
const skip = config.command === 'serve' || config.build.ssr
Expand All @@ -17,6 +17,11 @@ export function dynamicImportPolyfillPlugin(config: ResolvedConfig): Plugin {
if (id === polyfillId) {
return id
}
if (id === 'vite/dynamic-import-polyfill') {
this.error(
`The 'vite/dynamic-import-polyfill' is deprecated, Please use '/vite/dynamic-import-polyfill'.`
)
}
},
load(id) {
if (id === polyfillId) {
Expand Down