Skip to content

Commit

Permalink
Merge pull request #209 from jaredwray/ESM-Support-Only-as-CommonJS-d…
Browse files Browse the repository at this point in the history
…idnt-even-work

ESM Support Only as CommonJS didn't even work
  • Loading branch information
jaredwray authored Oct 6, 2024
2 parents da94843 + b5add04 commit e787c80
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ Ecto is a modern template consolidation engine that enables the best template en
* [Only the Top Template Engines](#only-the-top-template-engines-and-their-extensions): EJS, Markdown, Pug, Nunjucks, Mustache, Liquid, and Handlebars.
* Maintained with Monthly Updates!

## ESM and Node Version Support

This package is ESM only and tested on the current lts version and its previous. Please don't open issues for questions regarding CommonJS / ESM or previous Nodejs versions. To learn more about using ESM please read this from `sindresorhus`: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

-----

## Getting Started
Expand Down
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
"version": "4.1.0",
"description": "Modern Template Consolidation Engine for EJS, Markdown, Pug, Nunjucks, Liquid, and Handlebars",
"type": "module",
"main": "./dist/ecto.cjs",
"main": "./dist/ecto.js",
"module": "./dist/ecto.js",
"types": "./dist/ecto.d.ts",
"exports": {
".": {
"require": "./dist/ecto.cjs",
"import": "./dist/ecto.js"
}
},
Expand All @@ -22,7 +21,7 @@
"watch": "tsc -w -p .",
"clean": "rimraf ./dist yarn.lock package-lock.json pnpm-lock.yaml ./coverage ./node_modules ./site/readme.md ./dist-site",
"test": "xo --fix && vitest run --coverage",
"compile": "rimraf ./dist && tsup src/ecto.ts --format cjs,esm --dts --clean",
"compile": "rimraf ./dist && tsup src/ecto.ts --format esm --dts --clean",
"build": "rimraf ./dist && npm run compile",
"prepare": "rimraf ./dist && npm run compile",
"website:build": "rimraf ./site/readme.md && npx -y docula build -s ./site -o ./dist-site",
Expand All @@ -49,13 +48,13 @@
"liquidjs"
],
"dependencies": {
"@jaredwray/fumanchu": "^2.0.0",
"@jaredwray/fumanchu": "^2.1.0",
"ejs": "^3.1.10",
"liquidjs": "^10.17.0",
"nunjucks": "^3.2.4",
"pug": "^3.0.3",
"underscore": "^1.13.7",
"writr": "^4.1.0"
"writr": "^4.1.1"
},
"devDependencies": {
"@types/ejs": "^3.1.5",
Expand Down
5 changes: 3 additions & 2 deletions src/engines/handlebars.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-argument */
import fs from 'node:fs';
import * as _ from 'underscore';
import fumanchu from '@jaredwray/fumanchu';
import {BaseEngine} from '../base-engine.js';
import type {EngineInterface} from '../engine-interface.js';

Expand All @@ -12,8 +13,8 @@ export class Handlebars extends BaseEngine implements EngineInterface {

this.names = ['handlebars', 'mustache'];
this.opts = options;
// eslint-disable-next-line @typescript-eslint/no-require-imports, unicorn/prefer-module
this.engine = require('@jaredwray/fumanchu');

this.engine = fumanchu;

this.setExtensions(['hbs', 'hjs', 'handlebars', 'mustache']);
}
Expand Down

0 comments on commit e787c80

Please sign in to comment.