Skip to content

Commit

Permalink
docs: clarify code comments in optimize-missing-deps (#7332)
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann authored May 4, 2022
1 parent 2b58cb3 commit 70f032f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/playground/optimize-missing-deps/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ async function createServer(root = process.cwd()) {
let template = fs.readFileSync(resolve('index.html'), 'utf-8')
template = await vite.transformIndexHtml(req.originalUrl, template)

// this will import missing deps nest built-in deps that should not be optimized
// `main.js` imports dependencies that are yet to be discovered and optimized, aka "missing" deps.
// Loading `main.js` in SSR should not trigger optimizing the "missing" deps
const { name } = await vite.ssrLoadModule('./main.js')

// this will import missing deps that should be optimized correctly
// Loading `main.js` in the client should trigger optimizing the "missing" deps
const appHtml = `<div id="app">${name}</div>
<script type='module'>
import { name } from './main.js'
Expand Down

0 comments on commit 70f032f

Please sign in to comment.