Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Eleventy v3.0.0 fully supports ESM. - ref: https://github.com/11ty/eleventy/releases/tag/v3.0.0 Additionally, using `require("@11ty/eleventy")` with Eleventy v3.0.0 results in compatibility issues as follows. Therefore, this is an appropriate time to migrate our configuration from CommonJS to ESM. ``` > [email protected] build:11ty > eleventy --pathprefix=hotwire_ja [11ty] Eleventy Error (CLI): [11ty] 1. Error in your Eleventy config file '.eleventy.js'. (via EleventyConfigError) [11ty] 2. `require("@11ty/eleventy")` is incompatible with Eleventy v3 and this version of Node. You have a few options: [11ty] 1. (Easiest) Change the `require` to use a dynamic import inside of an asynchronous CommonJS configuration [11ty] callback, for example: [11ty] [11ty] module.exports = async function { [11ty] const {EleventyRenderPlugin, EleventyI18nPlugin, EleventyHtmlBasePlugin} = await import("@11ty/eleventy"); [11ty] } [11ty] [11ty] 2. (Easier) Update the JavaScript syntax in your configuration file from CommonJS to ESM (change `require` [11ty] to use `import` and rename the file to have an `.mjs` file extension). [11ty] [11ty] 3. (More work) Change your project to use ESM-first by adding `"type": "module"` to your package.json. Any [11ty] `.js` will need to be ported to use ESM syntax (or renamed to `.cjs`.) [11ty] [11ty] 4. (Short term workaround) Use the --experimental-require-module flag to enable this behavior. Read [11ty] more: https://nodejs.org/api/modules.html#loading-ecmascript-modules-using-require It is possible that the [11ty] newest version of Node has this enabled by default—you can try upgrading your version of Node.js. ERROR: "build:11ty" exited with 1. ```
- Loading branch information