From b5add04268f141ee3950d17d6fe8c581ea4ee658 Mon Sep 17 00:00:00 2001 From: Jared Wray Date: Sun, 6 Oct 2024 09:11:18 -0700 Subject: [PATCH] ESM Support Only as CommonJS didnt even work --- README.md | 4 ++++ package.json | 9 ++++----- src/engines/handlebars.ts | 5 +++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7c9f4e1..39842d5 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/package.json b/package.json index a362993..4c125a6 100644 --- a/package.json +++ b/package.json @@ -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" } }, @@ -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", @@ -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", diff --git a/src/engines/handlebars.ts b/src/engines/handlebars.ts index fb9c636..73f706e 100644 --- a/src/engines/handlebars.ts +++ b/src/engines/handlebars.ts @@ -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'; @@ -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']); }