Skip to content

Commit

Permalink
fix: [cloudflare workers] do not import plugin code in prod (#1)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: `import ssr from 'vite-plugin-ssr'` now throws an error; use `import ssr from 'vite-plugin-ssr/plugin'` instead.
  • Loading branch information
brillout committed Apr 7, 2021
1 parent e2a809e commit a6af9e7
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@ import './user-files/infra.node'
export { createPageRender } from './createPageRender.node'
export { html } from './html.node'

// Add depecration warning
import { plugin } from './plugin'
import { assertWarning } from './utils'

export default pluginWithWarning
function pluginWithWarning(): ReturnType<typeof plugin> {
assertWarning(
// Plugin should be imported from `vite-plugin-ssr/plugin`
import { assertUsage } from './utils'
export default pluginWrongImport
function pluginWrongImport(): never {
assertUsage(
false,
"`import ssr from 'vite-plugin-ssr';` is depecrated: use `import ssr from 'vite-plugin-ssr/plugin';` instead. This will break in a future versions."
"`import ssr from 'vite-plugin-ssr';` is depecrated: use `import ssr from 'vite-plugin-ssr/plugin';` instead."
)
return plugin()
}

// Enable `const ssr = require('vite-plugin-ssr')`
Expand Down

0 comments on commit a6af9e7

Please sign in to comment.