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

Incorrect SSR transform #1646

Closed
2 of 3 tasks
egoist opened this issue Jan 22, 2021 · 0 comments
Closed
2 of 3 tasks

Incorrect SSR transform #1646

egoist opened this issue Jan 22, 2021 · 0 comments

Comments

@egoist
Copy link
Contributor

egoist commented Jan 22, 2021

⚠️ IMPORTANT ⚠️ Please check the following list before proceeding. If you ignore this issue template, your issue will be directly closed.

  • Read the docs.
  • Use Vite >=2.0. (1.x is no longer supported)
  • If the issue is related to 1.x -> 2.0 upgrade, read the Migration Guide first.

Describe the bug

Incorrect code transform by vite.ssrLoadModule.

Reproduction

Test:

import { ssrTransform } from 'vite/src/node/ssr/ssrTransform'
;(async () => {
  console.log('// Code 1:')
  const result = await ssrTransform(`
  import {createApp} from 'vue';
  export {createApp}
  `)

  console.log(result.code)

  console.log('\n// Code 2:')

  const result2 = await ssrTransform(`
  export * from 'vue'
  `)

  console.log(result2.code)
})()

Output:

// Code 1:

  const __vite_ssr_import_0__ = __vite_ssr_import__("vue")

  __vite_ssr_import_0__.createApp
  
Object.defineProperty(__vite_ssr_exports__, "createApp", { get(){ return createApp }})

// Code 2:

  const __vite_ssr_import_0__ = __vite_ssr_import__("vue")
export * from 'vue'
  
__vite_ssr_exportAll__(__vite_ssr_import_0__)

System Info

  • vite version: 2.0.0-beta.37
  • Operating System:
  • Node version:
  • Package manager (npm/yarn/pnpm) and version:

Logs (Optional if provided reproduction)

  1. Run vite or vite build with the --debug flag.
  2. Provide the error log here.
@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant