express icon indicating copy to clipboard operation
express copied to clipboard

Use of name 'express' in JSX template engine name

Open dqh-au opened this issue 1 year ago • 2 comments

I'm soon to release a JSX based template engine for Express (powered by NakedJSX), and I've tentatively named it @nakedjsx/express-jsx. I have opened this issue to ask whether you are comfortable with this use of the name 'express'.

Of course, 'express-jsx' by itself wouldn't be appropriate as it would create confusion about who made it. But perhaps given that it would live under the @nakedjsx org, the name used in all practical contexts would be the combined '@nakedjsx/express-jsx' which I like because it makes two things clear:

  1. It's not an official Express project
  2. It's a thing made by @nakedjsx that probably adds JSX to Express.

What are your thoughts?

dqh-au avatar Jun 10 '23 23:06 dqh-au

Hi @dqh-au thank you for reaching out on this, it is appreciated.

So my understanding of what you are saying is that there would be a module named @nakedjsx/express, is that right? I don't see any issue with that, at least I have no issue with such a name :) . Additionally, if you are saying that within NakedJSX (and sorry, I am reading about it now to get more familiar) you are saying someone would say to "render with 'express'" and under the hood it used this other module for the template engine, I think that is also perfectly fine instead of saying "render with 'express-jsx'".

You certainly know NakedJSX better than I, but if you want to have things directly use the name "express" vs "express-jsx" in order to template with Express, I don't see any issue with it, personally.

And of course as you flesh it out, I'm sure there are some places we can even add Express/NakedJSX links or usage to our website expressjs.com as well, if you like :)

dougwilson avatar Jun 10 '23 23:06 dougwilson

Hi @dougwilson, thank you, I really appreciate it! And links back once it's released would be fantastic.

It hadn't occurred to me that a module called @nakedjsx/express might be ok - that is indeed a nice succinct name.

And yes, there would be a module called '@nakedjsx/express', that starts NakedJSX in template engine mode and provides a template engine for express, used like this: (snippet taken from my current test project)

const { createExpressJsx } = require('@nakedjsx/express-jsx');

// ...

const options =
    {
        srcDir,
        output:
            {
                viewsDir,
                tmpDir,
                staticDir,
                staticUriPrefix
            }
    };
const expressJsx = createExpressJsx(options)

//
// Configure express to use @nakedjsx/express-jsx as template engine
//

app.engine('mjs', expressJsx.engine);
app.use(express.static(staticDir));
app.set('views', viewsDir);
app.set('view engine', 'mjs');

Usage sadly can't be quite as simple as other template engines, needs that little bit of setup above. Essentially NakedJSX watches a srcDir (containing NakedJSX pages) and generates ~~dummy *.jsx~~ HTML generating .mjs files in the views folder. ~~Those trick express into seeing a routed request as a valid template engine path, allowing @nakedjsx/express-jsx to forward the request to the running NakedJSX instance which executes an in-memory function compiled from the matching NakedJSX page to generate the HTML.~~

Those files are imported (once) into NakedJSX and executed in response to requests to generate HTML and other content on demand.

EDIT: things move quickly

dqh-au avatar Jun 11 '23 00:06 dqh-au