-
Notifications
You must be signed in to change notification settings - Fork 1
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
Refactor to ESM #110
Refactor to ESM #110
Conversation
@thewebartisan7 got most of the tests passing, just some related to props seem to fail and I'm not sure why. I'm thinking something is broken in or in Can you take a look and help if possible? Thanks! |
@Scrum forgot to mention you, if there's anything you can think of regarding |
Which error you get? |
Maybe this https://nodejs.org/api/vm.html#class-vmmodule ? |
Either Or assertion errors, because it fails to remove the attribute that was passed as a prop, for example this one: FAIL test/test-locals.js > Must process props with custom options
AssertionError: expected '<div title="My Component Title"><h1>M…' to be '<div><h1>My Component Title</h1></div…' // Object.is equality
- Expected
+ Received
- <div><h1>My Component Title</h1></div><div><span>Body</span>Content-My slot prop</div><div>My prop via locals attribute</div>
+ <div title="My Component Title"><h1>My Component Title</h1></div><div><span>Body</span>Content-My slot prop</div><div>My prop via locals attribute</div>
In this case I think moving away from |
It seems main problem is process-script.js as you said. I try to restore processScript to CommonJS and tests seems much better. You can also try:
Test result: I think error is just something related to expect of vite.
Honestly I don't have too much experience with VM contexts and I found that to run vm.Module is still experimental, see https://nodejs.org/api/vm.html#class-vmmodule (This feature is only available with the --experimental-vm-modules command flag enabled.). Need more investigation into this, but consider to keep this as-is for now if there are not alternative. About other issue in posthml-expression, I can't see how posthtml can run only in browser, am I missing something? What is the purpose of this? Is not the goal to just output HTML? |
Yeah but if we are to move to ESM this won't work, will investigate further myself.
You could transform HTML with it and its plugins right in the browser without running anything on the server like in a lambda function or similar. A more complex scenario would be being able to use Maizzle to render emails right in your browser, without the need of a server running Node. Basically, any tools that could transform HTML would benefit from this, you could even do drag and drop template builders for Maizzle and the like 👍 |
Although it is not ideal, I am almost certain that there is a way to configure it. |
OK, coming back to this I think we should merge the current dependency updates and we can deal with refactoring to ESM later.
If it's ok with you, I'll go ahead and merge the dependency updates and also update the plugin to install fewer dependencies 👍 |
This PR refactors the plugin to use ESM syntax. WIP.
I'll write a more detailed description once I make more progress.
The main goals here are: