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
fix: loop and iterate entry tags #522
fix: loop and iterate entry tags #522
Conversation
@zackspear Was my first thought too 🙃 Unfortunately we have to note one thing, the import between Therefore there was an extra counter ( Do you want to adjust this again? <% let i = 0; %><%= options.tags.map(function ({ async, name, path }) {
let tag;
if (async) {
tag = ` ['${name}', defineAsyncComponent(() => { return import('${path}').then(module => (typeof module.default === 'function' ? (new module.default).$options : module.default) ); })]`;
} else {
tag = ` ['${name}', (typeof Component${i} === 'function' ? (new Component${i}).$options : Component${i})]`;
i++;
}
return tag;
}).join(',\n') %> The |
@ThornWalli ah ok. Maybe you're wanting something like this? If so I can make another commit with this in the PR 😄 This seems to work in my local test environment. import { defineAsyncComponent, defineCustomElement } from 'vue'
<%= options.tags.filter(function ({ async }) { return !async; }).map(({ path }, i) => `import Component${i} from '${path}';`).join('\n') %>
const defineTags = () => {
const elements = [
<% let i = 0; %><%= options.tags.map(function ({ async, name, path }) {
let tag;
if (async) {
tag = ` ['${name}', defineAsyncComponent(() => { return import('${path}').then(module => (typeof module.default === 'function' ? (new module.default).$options : module.default) ); })]`;
} else {
tag = ` ['${name}', (typeof Component${i} === 'function' ? (new Component${i}).$options : Component${i})]`;
}
i++;
return tag;
}).join(',\n') %>
].forEach(([name, component]) => {
const CustomElement = defineCustomElement(component);
window.customElements.define(name, CustomElement);
})
};
const setup = () => {
defineTags();
};
setup(); |
The i++ must be in the else :) You can set the first component to When the PR is adjusted, I merge it in. import { defineAsyncComponent, defineCustomElement } from 'vue'
<%= options.tags.filter(function ({ async }) { return !async; }).map(({ path }, i) => `import Component${i} from '${path}';`).join('\n') %>
const defineTags = () => {
const elements = [
<% let i = 0; %><%= options.tags.map(function ({ async, name, path }) {
let tag;
if (async) {
tag = ` ['${name}', defineAsyncComponent(() => { return import('${path}').then(module => (typeof module.default === 'function' ? (new module.default).$options : module.default) ); })]`;
} else {
tag = ` ['${name}', (typeof Component${i} === 'function' ? (new Component${i}).$options : Component${i})]`;
i++;
}
return tag;
}).join(',\n') %>
].forEach(([name, component]) => {
const CustomElement = defineCustomElement(component);
window.customElements.define(name, CustomElement);
})
};
const setup = () => {
defineTags();
};
setup(); |
🎉 This PR is included in version 2.0.0-beta.13 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Fix for #521
Multiple entry tags should now work