-
Notifications
You must be signed in to change notification settings - Fork 395
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
engine-server/template-compiler: remove parse5 utils #3785
Conversation
Thanks for the contribution! Before we can merge this, we need @43081j to sign the Salesforce Inc. Contributor License Agreement. |
44a019e
to
764cb64
Compare
i did sign the CLA btw but seems to have not picked it up 🤔 |
@43081j For ESM dependencies, we are currently pre-bundling those into our own commonjs/ESM outputs, to avoid passing on the To bundle up lwc/scripts/rollup/rollup.config.js Lines 133 to 138 in 1c1687e
It will also need to be added to the lwc/packages/@lwc/template-compiler/package.json Lines 53 to 57 in 1c1687e
If you do this, then the dep should be bundled into I just realized though that we missed this step in #3602; we'll open up a separate PR to fix that. As for the CLA – you may have to push an empty commit to the branch to re-trigger the CLA check. 🙂 |
Fixing the devDeps issue here, you may have some merge conflicts after it gets merged: #3786 |
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.
This LGTM except for the merge conflict/devDeps issue that needs to be resolved, but I would like @divmain to take a look too.
Thank you so much for the PR!! 🙇
no worries, i'll update per the comments 👍 LWC is one of the last few major projects i've been updating parse5 and moving to p5 tools in. so will be good to get it done! |
This does a couple of things: - Introduces `@parse5/tools` to replace any parse5 AST utilities we had - Removes custom parse5 types (since they are now shipped)
764cb64
to
1b74965
Compare
@nolanlawson i made the changes but, locally at least, build fails still when trying to build the playground:
|
@43081j When I build your branch locally, it works fine for me. I can also see that I will kick off a CI test of your code! |
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.
This is fantastic! Thanks again for the contribution and for reading my mind in the parse5 PR!
@@ -6,11 +6,11 @@ | |||
*/ | |||
|
|||
import * as parse5 from 'parse5'; | |||
import type { DefaultTreeAdapterMap } from 'parse5'; | |||
import {DocumentFragment} from '@parse5/tools'; |
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.
import {DocumentFragment} from '@parse5/tools'; | |
import { DocumentFragment } from '@parse5/tools'; |
@nolanlawson it was some nx caching stuff, @divmain no worries, thanks for sorting the parse5 upgrade too. once the new version is published, we can remove the ts-ignore flags too |
the build failure seems like it has transformed to cjs but kept the not too sure whats going on there |
interesting, do you know why that solves the problem? why doesn't ts-jest figure out ESM? are we basically working around ts-jest by using babel on esm dependencies separately? sorry for so many questions, just making sure i understand the root of the problem as for the failing test... its an awkward one. parse5 parses this as a template node (i.e. it has <template>
foo
</template> however, it parses this an element with the nodename/tagname <svg>
<template>
foo
</template>
</svg> i suspect this is because a i've worked around it by only using |
I think it's that Jest just has problems with Native Node ESM ( |
Also, |
/nucleus test |
Thank you again! |
Details
I had a branch hanging around waiting for inikulin/parse5#996, which upgraded parse5 in this repo to 7.x
While waiting, this was partially done in #3602 (partially because we're still waiting for the parse5 update, just using ts-ignore meanwhile).
One thing that branch didn't have, which would be good to still sort: removal of the parse5 utils in LWC.
Basically, LWC ships its own parse5 utils for things like quick access to tree adapter types, etc.
All of this has been available for a while in a
@parse5/tools
package.So i've rebased my original PR back onto master, which has left us with the migration to
@parse5/tools
.Failing build
Currently, it won't build as
@parse5/tools
is ESM-only and our target appears to be commonjs. How did you solve this elsewhere? @nolanlawson i saw you did some stuff around this for parse5 itself, could you point me in the right direction?Does this pull request introduce a breaking change?
Does this pull request introduce an observable change?