Git Product home page Git Product logo

Comments (10)

shepherdwind avatar shepherdwind commented on July 25, 2024 1

I've recently been rewriting my code using typescript. I'll post an ESM package when I'm done. Thanks for you code example.

from velocity.js.

bseib avatar bseib commented on July 25, 2024

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

from velocity.js.

shepherdwind avatar shepherdwind commented on July 25, 2024

@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?

from velocity.js.

bseib avatar bseib commented on July 25, 2024

@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.

from velocity.js.

bseib avatar bseib commented on July 25, 2024

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 package.json to point at your new BETA version.

from velocity.js.

shepherdwind avatar shepherdwind commented on July 25, 2024

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 package.json to point at your new BETA version.

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.

from velocity.js.

bseib avatar bseib commented on July 25, 2024

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 x.id that worked in javascript.

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.

from velocity.js.

bseib avatar bseib commented on July 25, 2024

@shepherdwind I think VELOCITY_AST needs to be exported at the top level. That is the type returned when calling parse, and the caller will need that type to do anything useful. I tried to import it directly, i.e.,

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'

from velocity.js.

bseib avatar bseib commented on July 25, 2024

@shepherdwind The second issue I'm seeing is a runtime error:

image

The sources are not in the distribution, but it looks like this may be referring to here:

export class BlockCommand extends Compile {

Maybe there is no default constructor up the chain of classes? Not sure what's going on there...

from velocity.js.

shepherdwind avatar shepherdwind commented on July 25, 2024

@shepherdwind The second issue I'm seeing is a runtime error:

image

The sources are not in the distribution, but it looks like this may be referring to here:

export class BlockCommand extends Compile {

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.

from velocity.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.