-
Notifications
You must be signed in to change notification settings - Fork 112
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(vue): apply vue component name to wrapper #257
Conversation
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.
I think the reason why I opted not to make this change before was that it broke treeshaking with Webpack. Can you make a dev/prerelease build and I can help verify this with you?
Can do 👍 we are taking advantage of this pattern in some if the manual wrappers in Ionic Vue (but not all). Dev build: Framework branch using dev-build + fixes manual wrappers: |
This is the results in Ionic Vue 6.1.2:
This is the results using a dev build from your FW-1403 branch:
It looks like either webpack/Vue CLI fixed a lot of issues with treeshaking, but I do notice an increase in size with I am testing on https://github.com/liamdebeasi/ionic-vue-treeshaking which only imports a single Dev build with your changes: 6.1.3-dev.11651002603.1969dbdc Are you able to identify what's been added/changed between the two builds? |
Ok digging into the output a couple things stand-out; one I ran The only other diff that is noticeable is this portion (putting inside a collapsible section): Feature: const kt = (e) => e.__isTeleport,
St = (e) => e && (e.disabled || "" === e.disabled),
Ct = (e) =>
"undefined" !== typeof SVGElement && e instanceof SVGElement,
_t = (e, t) => {
const n = e && e.to;
if ((0, r.HD)(n)) {
if (t) {
const e = t(n);
return e;
}
return null;
}
return n;
},
Rt = {
__isTeleport: !0,
process(e, t, n, o, r, i, a, s, l, c) {
const {
mc: d,
pc: u,
pbc: p,
o: {
insert: h,
querySelector: f,
createText: m,
createComment: g,
},
} = c,
$ = St(t.props);
let { shapeFlag: b, children: v, dynamicChildren: y } = t;
if (null == e) {
const e = (t.el = m("")),
c = (t.anchor = m(""));
h(e, n, o), h(c, n, o);
const u = (t.target = _t(t.props, f)),
p = (t.targetAnchor = m(""));
u && (h(p, u), (a = a || Ct(u)));
const g = (e, t) => {
16 & b && d(v, e, t, r, i, a, s, l);
};
$ ? g(n, c) : u && g(u, p);
} else {
t.el = e.el;
const o = (t.anchor = e.anchor),
d = (t.target = e.target),
h = (t.targetAnchor = e.targetAnchor),
m = St(e.props),
g = m ? n : d,
b = m ? o : h;
if (
((a = a || Ct(d)),
y
? (p(e.dynamicChildren, y, g, r, i, a, s), wt(e, t, !0))
: l || u(e, t, g, b, r, i, a, s, !1),
$)
)
m || Lt(t, n, o, c, 1);
else if ((t.props && t.props.to) !== (e.props && e.props.to)) {
const e = (t.target = _t(t.props, f));
e && Lt(t, e, null, c, 0);
} else m && Lt(t, d, h, c, 1);
}
},
remove(e, t, n, o, { um: r, o: { remove: i } }, a) {
const {
shapeFlag: s,
children: l,
anchor: c,
targetAnchor: d,
target: u,
props: p,
} = e;
if ((u && i(d), (a || !St(p)) && (i(c), 16 & s)))
for (let h = 0; h < l.length; h++) {
const e = l[h];
r(e, t, n, !0, !!e.dynamicChildren);
}
},
move: Lt,
hydrate: Tt,
};
function Lt(e, t, n, { o: { insert: o }, m: r }, i = 2) {
0 === i && o(e.targetAnchor, t, n);
const { el: a, anchor: s, shapeFlag: l, children: c, props: d } = e,
u = 2 === i;
if ((u && o(a, t, n), (!u || St(d)) && 16 & l))
for (let p = 0; p < c.length; p++) r(c[p], t, n, 2);
u && o(s, t, n);
}
function Tt(
e,
t,
n,
o,
r,
i,
{ o: { nextSibling: a, parentNode: s, querySelector: l } },
c
) {
const d = (t.target = _t(t.props, l));
if (d) {
const l = d._lpa || d.firstChild;
16 & t.shapeFlag &&
(St(t.props)
? ((t.anchor = c(a(e), t, s(e), n, o, r, i)),
(t.targetAnchor = l))
: ((t.anchor = a(e)), (t.targetAnchor = c(l, t, d, n, o, r, i))),
(d._lpa = t.targetAnchor && a(t.targetAnchor)));
}
return t.anchor && a(t.anchor);
}
const Nt = Rt,
At = "components";
function Et(e, t) {
return Mt(At, e, !0, t) || e;
} Main: const kt = (e) => e.__isTeleport;
const St = "components";
function Ct(e, t) {
return Rt(St, e, !0, t) || e;
} ☝️ this seems tied to possibly inline overlays and the way they are proxied. I will test with not naming those and see if that chunk disappears tomorrow. |
Ok, figured it out 🎉 The problem was not from this repo or this PR, but from the changes to the manual wrappers. Many of the manual wrappers had
This wasn't probably caught, as most of the manual wrappers are essential components for any Ionic application and are commonly imported into the bundle anyways. Here is the updated dev-build of the branch to test with in the treeshaking repo: |
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.
I am getting some compilation errors with the latest dev build in Vite only:
src/views/About.vue:17:8 - error TS2322: Type '{}' is not assignable to type 'IntrinsicAttributes & Partial<{}> & Omit<Readonly<{ toString?: string | undefined; valueOf?: unknown; toLocaleString?: string | undefined; disabled?: boolean | undefined; ... 21 more ...; shape?: "round" | undefined; }> & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>'.
Type '{}' is not assignable to type 'Omit<Readonly<{ toString?: string | undefined; valueOf?: unknown; toLocaleString?: string | undefined; disabled?: boolean | undefined; strong?: boolean | undefined; fill?: "default" | "clear" | "outline" | "solid" | undefined; ... 19 more ...; shape?: "round" | undefined; }> & VNodeProps & AllowedComponentProps & Co...'.
Types of property 'toString' are incompatible.
Type '() => string' is not assignable to type 'string & (() => string)'.
17 <ion-button @click="showModal">Open Modal</ion-button>
~~~~~~~~~~
I added a "vite" branch to https://github.com/liamdebeasi/ionic-vue-treeshaking. That example shows a Vite + Ionic Vue starter app with v6.1.3. It should build successfully -- then install your dev build and try and run npm run build
again. You should get the above error.
f528d2f
to
1549fe0
Compare
Did a bit more digging. This issue can be fixed by setting When Vue gets the component name, it will use However, it will also fall back to Vue Dev Tools appears to only consider https://github.com/vuejs/devtools/blob/74eccb02fb57d9f12acc3d890a09ac291d843fff/packages/app-frontend/src/features/components/ComponentTreeNode.vue#L30 |
@liamdebeasi I think I'm missing a little context. I'm not sure what the state of this PR was before 1549fe0 was pushed. Were there additional/different changes in the prior commit(s) that were causing your tree shaking concerns and build issues? Is https://github.com/liamdebeasi/ionic-vue-treeshaking up to date/could I use that with a dev build of this branch to test this out? |
Actually! It looks like this PR is no longer needed. I think I had an old version of the Vue Dev Tools installed. Vue Dev Tools does indeed support Updating to the latest Vue Dev Tools reveals that the components generated by |
Does this mean we can also close #143 as well? |
Yep, I can close that. |
Not sure what happened, but this is indeed still a bug. Steps to repro
Dev Build Stencil Output Target Dev Build: You can install the Ionic Dev Build and follow the same steps above. Observe that in step 5 the component displayed is using its component name. Install Example: |
Here is the old code before I pushed my new fix: f528d2f This code changed from using a functional component to a component with a |
<!-- Please refer to our contributing documentation for any questions on submitting a pull request, or let us know here if you need any help: https://ionicframework.com/docs/building/contributing --> <!-- Some docs updates need to be made in the `ionic-docs` repo, in a separate PR. See https://github.com/ionic-team/ionic-framework/blob/main/.github/CONTRIBUTING.md#modifying-documentation for details. --> <!-- Please do not submit updates to dependencies unless it fixes an issue. --> <!-- Please try to limit your pull request to one type (bugfix, feature, etc). Submit multiple pull requests if needed. --> ## What is the current behavior? <!-- Please describe the current behavior that you are modifying. --> <!-- Issues are required for both bug fixes and features. --> Issue URL: resolves #25199 Vue components show up as "Anonymous Component" in Vue Dev Tools. This is caused by our use of `displayName` instead of `name`. This required a fix in the Vue Output Target package. See ionic-team/stencil-ds-output-targets#257 for more info. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - Updates the Vue Output Target dependency - Functional components created manually in Ionic Vue now set `name` instead of `displayName`. Note: Non-functional components were never impacted by this bug. ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change, please describe the impact and migration path for existing applications below. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. --> Dev build: `7.0.2-dev.11681308435.141a05de`
<!-- Please refer to our contributing documentation for any questions on submitting a pull request, or let us know here if you need any help: https://ionicframework.com/docs/building/contributing --> <!-- Some docs updates need to be made in the `ionic-docs` repo, in a separate PR. See https://github.com/ionic-team/ionic-framework/blob/main/.github/CONTRIBUTING.md#modifying-documentation for details. --> <!-- Please do not submit updates to dependencies unless it fixes an issue. --> <!-- Please try to limit your pull request to one type (bugfix, feature, etc). Submit multiple pull requests if needed. --> ## What is the current behavior? <!-- Please describe the current behavior that you are modifying. --> <!-- Issues are required for both bug fixes and features. --> Issue URL: resolves #25199 Vue components show up as "Anonymous Component" in Vue Dev Tools. This is caused by our use of `displayName` instead of `name`. This required a fix in the Vue Output Target package. See ionic-team/stencil-ds-output-targets#257 for more info. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - Updates the Vue Output Target dependency - Functional components created manually in Ionic Vue now set `name` instead of `displayName`. Note: Non-functional components were never impacted by this bug. ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change, please describe the impact and migration path for existing applications below. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. --> Dev build: `7.0.2-dev.11681308435.141a05de`
<!-- Please refer to our contributing documentation for any questions on submitting a pull request, or let us know here if you need any help: https://ionicframework.com/docs/building/contributing --> <!-- Some docs updates need to be made in the `ionic-docs` repo, in a separate PR. See https://github.com/ionic-team/ionic-framework/blob/main/.github/CONTRIBUTING.md#modifying-documentation for details. --> <!-- Please do not submit updates to dependencies unless it fixes an issue. --> <!-- Please try to limit your pull request to one type (bugfix, feature, etc). Submit multiple pull requests if needed. --> ## What is the current behavior? <!-- Please describe the current behavior that you are modifying. --> <!-- Issues are required for both bug fixes and features. --> Issue URL: resolves #25199 Vue components show up as "Anonymous Component" in Vue Dev Tools. This is caused by our use of `displayName` instead of `name`. This required a fix in the Vue Output Target package. See ionic-team/stencil-ds-output-targets#257 for more info. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - Updates the Vue Output Target dependency - Functional components created manually in Ionic Vue now set `name` instead of `displayName`. Note: Non-functional components were never impacted by this bug. ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change, please describe the impact and migration path for existing applications below. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. --> Dev build: `7.0.2-dev.11681308435.141a05de`
Pull request checklist
Please check if your PR fulfills the following requirements:
npm run build
) was run locally for affected output targetsnpm test
) were run locally and passedPull request type
Please check the type of change your PR introduces:
What is the current behavior?
Generated Vue component wrappers display as
AnonymousComponent
in Vue dev tools.Issue URL: resolves #143
What is the new behavior?
Generated Vue component wrappers will correctly display as their pascal case component name in dev tools.
Does this introduce a breaking change?
Other information
This PR is in favor of #162.