11ty / eleventy-plugin-webc

Adds support for WebC *.webc files to Eleventy
https://www.11ty.dev/docs/languages/webc/
120 stars 10 forks source link

ESM for Eleventy 3.0 #91

Closed ghost closed 10 months ago

ghost commented 11 months ago

If anyone is using this plugin with the alpha builds of Eleventy 3.0, this patch will work as a temporary fix until the plugin is updated properly:

diff --git a/node_modules/@11ty/eleventy-plugin-webc/src/eleventyWebcTemplate.js b/node_modules/@11ty/eleventy-plugin-webc/src/eleventyWebcTemplate.js
index 3aeb86e..41a2c5a 100644
--- a/node_modules/@11ty/eleventy-plugin-webc/src/eleventyWebcTemplate.js
+++ b/node_modules/@11ty/eleventy-plugin-webc/src/eleventyWebcTemplate.js
@@ -1,8 +1,11 @@
 const path = require("path");
 const debug = require("debug")("Eleventy:WebC");

-const { EleventyRenderPlugin } = require("@11ty/eleventy");
-const CompileString = EleventyRenderPlugin.String;
+let CompileString;
+(async () => {
+  const { EleventyRenderPlugin } = await import("@11ty/eleventy");
+  CompileString = EleventyRenderPlugin.String;
+})();

 function relativePath(inputPath, newGlob) {
    // project root

This becomes irrelevant with the completion of https://github.com/11ty/eleventy/issues/2840

zachleat commented 10 months ago

Fix shipped with v0.11.2, thank you!

zachleat commented 10 months ago

Notably, this was still required if folks are using Eleventy WebC in CJS projects in 3.0!