From 9885b7008d9cf95a2f4ef6cc53e4fc3013f40038 Mon Sep 17 00:00:00 2001 From: Wouter Van Schandevijl Date: Mon, 14 Jul 2025 20:22:38 +0200 Subject: [PATCH] integration: document how to use the --esm for JS Module type import/export + usage --- src/guide/installation/integrations.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/guide/installation/integrations.md b/src/guide/installation/integrations.md index dbffacda..021307e8 100644 --- a/src/guide/installation/integrations.md +++ b/src/guide/installation/integrations.md @@ -68,3 +68,21 @@ The most recent one is: https://www.npmjs.com/package/@inventory/parcel-plugin-h TODO: Write text here https://www.npmjs.com/package/parcel-plugin-handlebars-precompile + + +## JavaScript Modules + +When precompiling using the CLI, use the `--esm handlebars` option. + +```sh +npx handlebars your.handlebars -f your.js --esm handlebars +``` + +And then import it like so: + +```js +import Handlebars from 'handlebars'; +import './your.js'; + +const result = Handlebars.templates['your'](data); +```