-
Notifications
You must be signed in to change notification settings - Fork 143
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
ESM module build? #151
Comments
Here is my fork as an example of how to get it to build an ESM compatible build. https://github.com/Gentomi/velocity.js The changes needed: master...Gentomi:velocity.js:master |
I've recently been rewriting my code using typescript. I'll post an ESM package when I'm done. Thanks for you code example. |
@bseib now I published new beta version 2.1.0-beta, Can you help me to check if this version is work ok with esm module? |
Hey awesome @shepherdwind. I should have a chance to look at it this weekend. |
Hey @shepherdwind , do you have any plans to release your BETA branch to npm? That would make testing a lot simpler -- I would just update my |
https://www.npmjs.com/package/velocityjs/v/2.1.0-beta this beta version is the new one, you can just try this. I had published it a week ago. |
Ah, thank you, I missed that somehow. Things look pretty good. I have one snippet of code left to fix, and I haven't dug in yet to see what's going on. My function was parsing a velocity template, then looking through the abstract syntax tree to get all the parameter names that were found. I need to figure out the typescript equivalent for const parseOutParamNames: ((template: string) => string[]) = (template: string) => {
const astArray = (vjs.parse(template)) as Array<VELOCITY_AST>
return astArray.filter((x) => {
return typeof x === 'object'
}).map((x) => {
return x.id
})
} I ought to be able to make a new function that is cleaner with respect to types now that the underlying code is also in typescript. |
@shepherdwind I think import {VELOCITY_AST} from "velocityjs/dist/types/type" However that lead to other compilation issues. I ought to be able to simply do: import {parse, render, VELOCITY_AST} from 'velocityjs' |
@shepherdwind The second issue I'm seeing is a runtime error: The sources are not in the distribution, but it looks like this may be referring to here: velocity.js/src/compile/blocks.ts Line 10 in dd6c461
Maybe there is no default constructor up the chain of classes? Not sure what's going on there... |
Can you provide me you code? I just try this in node. It is better to have a project that can reproduce the whole scene. |
I
I see this problem too |
Have you considered building the lib so that it is ESM compatible? I.e. for modern tooling that uses
import
statements rather thanrequire()
, and can do tree-shaking optimizations, etc. Here's an example library project setup usingesbuild
.The text was updated successfully, but these errors were encountered: