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

feat: support pre-bundle #187

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

aa900031
Copy link

@aa900031 aa900031 commented Jun 14, 2023

Description

As mentioned in this vitejs/vite#3910, external files (.vue) not pre-bundle in Vite. According to the discussion thread, it has been confirmed that Svelte already supports this feature. So, here we will implement the same approach to enable Vite Pre-bundling for Vue SFC.

I believe this feature would be very helpful for Vue SFC library development. With the help of https://github.com/unjs/mkdist, we can perform transform and directly publish it to npm. When developers who use this library want to deploy their websites, they can rely on the installed @vue/compiler-sfc to compile the SFCs within the library.


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@aa900031
Copy link
Author

@sxzz Please check this PR, Welcome to discussion. Thank you.

packages/plugin-vue/README.md Outdated Show resolved Hide resolved
packages/plugin-vue/README.md Outdated Show resolved Hide resolved
packages/plugin-vue/src/index.ts Outdated Show resolved Hide resolved
packages/plugin-vue/src/prebundle.ts Outdated Show resolved Hide resolved
packages/plugin-vue/src/prebundle.ts Outdated Show resolved Hide resolved
packages/plugin-vue/src/prebundle.ts Outdated Show resolved Hide resolved
packages/plugin-vue/src/prebundle.ts Outdated Show resolved Hide resolved
packages/plugin-vue/src/prebundle.ts Outdated Show resolved Hide resolved
packages/plugin-vue/src/prebundle.ts Outdated Show resolved Hide resolved
packages/plugin-vue/src/prebundle.ts Outdated Show resolved Hide resolved
@aa900031
Copy link
Author

Hi @sxzz! Thank you for the review. I've resolved all the comments. Please check it again

packages/plugin-vue/src/index.ts Outdated Show resolved Hide resolved
packages/plugin-vue/src/index.ts Show resolved Hide resolved
@sxzz
Copy link
Member

sxzz commented Aug 26, 2023

Try to run cd ./playground/vue-sfc-prebundle && pnpm vite optimize --force && pnpm dev and there's an error.

Uncaught TypeError: Cannot read properties of undefined (reading '__vccOpts')
    at plugin_vue_export_helper_default (@vitejs_test-lib-component.js?v=574ab827:9:22)
    at @vitejs_test-lib-component.js?v=574ab827:58:21

@aa900031
Copy link
Author

aa900031 commented Aug 26, 2023

@sxzz I have same error now, but after reverting to the code before the merge f85e9c6, everything is back to normal.

This is quite unusual. I should spend more time confirming where the issue might be.

@aa900031
Copy link
Author

@sxzz I've discovered the prebundle is not handling TypeScript-related content (hence the errors when importing CompC.vue and CompD.vue). So, I'm making theprebundle transforms consistent with the original transforms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants