Skip to content
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 #160

Open
cossssmin opened this issue Feb 29, 2024 · 10 comments
Open

Refactor to ESM #160

cossssmin opened this issue Feb 29, 2024 · 10 comments

Comments

@cossssmin
Copy link
Member

cossssmin commented Feb 29, 2024

@Scrum I'd like to work on a new major release for posthtml-expressions that would include:

  • refactoring code to ESM-only
  • require Node.js 18+
  • migrate tests to use Vitest
  • switch style linting to eslint
  • add type definitions

Please let me know if you're OK with this and I'll start work on the PR. Thanks!

@Scrum
Copy link
Member

Scrum commented Feb 29, 2024

@cossssmin I'm glad you can do it, thank you!

@cossssmin
Copy link
Member Author

Thanks, will get started and let you know when it's ready for review.

Did you have any plans for it? We could add them in this refactor.

@Scrum
Copy link
Member

Scrum commented Mar 1, 2024

Did you have any plans for it? We could add them in this refactor.

There were a couple of ideas:

  • use tsup or vitejs as a collector,
  • use the general prettier rules,
  • use the general rules for typescript,
  • general rules for vscode/idea,
  • configure ci/cd (install, test, optional build, publish by tag or after the merge),
  • consider turborepo

@cossssmin
Copy link
Member Author

OK, I'd start on it and when I'm done you could add those maybe? Or do you prefer we launch a major version first and then add those ideas?

@Scrum
Copy link
Member

Scrum commented Mar 1, 2024

OK, I'd start on it and when I'm done you could add those maybe? Or do you prefer we launch a major version first and then add those ideas?

Rather, as you prefer, these are the best ideas)

@cossssmin
Copy link
Member Author

Could we take this opportunity to think about what options we have for replacing node:vm so that the plugin could be used in a browser environment? Would Function work?

This would be a game-changer for frameworks like Maizzle, you could run the entire PostHTML build chain right in the browser, no serverless/Lambdas needed.

@Scrum
Copy link
Member

Scrum commented Mar 18, 2024

It is necessary to explore this direction, in the first approximation it looks like vm-browserify

@cossssmin
Copy link
Member Author

I was looking at the Alpine.js evaluator the other day, maybe something like this would be enough?

https://github.com/alpinejs/alpine/blob/main/packages/alpinejs/src/evaluator.js

Didn't know about vm-browserify, looks like it's very popular but it's only for the browser and it creates an <iframe> for each code execution which leads to other issues like web workers not working.

@cossssmin
Copy link
Member Author

This also looks interesting, it uses @babel/parser to parse expressions:

https://github.com/william-yz/ts-expression-evaluator

@cossssmin
Copy link
Member Author

Another idea would be to create an interface and allow for various templating engine adapters. For example, there's LiquidJS that people could use instead of the default engine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants