-
Notifications
You must be signed in to change notification settings - Fork 156
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 custom blocks for Vue 3 #364
feat: support custom blocks for Vue 3 #364
Conversation
if (Array.isArray(customBlocksResult)) { | ||
customBlocksResult.forEach(codes => { | ||
codes.forEach(code => { | ||
node.add(`;((${componentNamespace}) => { ${code} })(exports.default);`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Custom blocks can now be handled for components like vue-loader
and @vitejs/plugin-vue
.
@@ -133,23 +134,28 @@ function processStyle(styles, filename, config) { | |||
|
|||
module.exports = function(src, filename, config) { | |||
const { descriptor } = parse(src, { filename }) | |||
const componentNamespace = | |||
getVueJestConfig(config)['componentNamespace'] || vueComponentNamespace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have added the componentNamespace
option to the vue-jest config.
This is because we want the transformer (parser) side of custom blocks to be able to handle them flexibly.
In the case of i18n custom blocks, we are using a common library for generic processing for various bundlers such as vue-i18n-loader, rollup-plugin-vue-i18n, and vite-plugin-vue-i18n. For example, it's handled the below:
In the code in the URL above, the component pass to the function, and uses the variable name Component
.
In order to reuse this logic in vue-jest transformer, I need to change it a bit, but in any case, being able to specify the variable name allows for flexible processing on the transformer side.
I will review this and port to Jest 27 in the near future, thanks for waiting. |
Hi! @lmiller1990 What do we do need additional work? |
Sorry I took a while to look at this. Seems fine! Let's release this right now. |
Thank you very much! ✨ ❤️ |
This is WIP pull request.As the title, I’ll support be transforming custom blocks for Vue 3.
At this time, only jest 26.x is supported.