You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
While Eleventy doesn’t support using ES Modules directly (i.e. as a config file or within _data/, ref. #836), it’s still possible to use dynamic import() syntax in CommonJS modules on recent Node.js versions. This is necessary to use ESM-only packages.
When the DEBUG environment variable is set, Eleventy requires the time-require package, which was last updated in 2014. It overrides Module._load to calculate timing information. This is called when requiring or importing a CommonJS module. time-require assumes that _load will be passed a module name and a parent. When ESM code tries to import a CommonJS module, Module._load is called with parent set to undefined. This results in a crash.
To Reproduce
Steps to reproduce the behavior:
In an Eleventy project, install camelcase
In your Eleventy config file, call import("camelcase")
run DEBUG='Eleventy:Benchmark*' npx @11ty/eleventy
See error
Expected behavior
No error, ideally helpful timing information is displayed for ES modules in addition to CommonJS ones.
Environment:
OS and Version: macOS 11.6 (20G165)
Eleventy Version 1.0.0-beta.8
Additional context
Ideally, either the time-require package would be forked, patched, and updated to work better with ES Modules.
As an alternative, it would be great to make the time-require import explicitly opt-in, allowing analysis of CJS-only projects without breaking perf debugging for CJS+ESM projects.
The text was updated successfully, but these errors were encountered:
Describe the bug
While Eleventy doesn’t support using ES Modules directly (i.e. as a config file or within
_data/
, ref. #836), it’s still possible to use dynamicimport()
syntax in CommonJS modules on recent Node.js versions. This is necessary to use ESM-only packages.When the
DEBUG
environment variable is set, Eleventy requires thetime-require
package, which was last updated in 2014. It overridesModule._load
to calculate timing information. This is called when requiring or importing a CommonJS module.time-require
assumes that_load
will be passed a module name and aparent
. When ESM code tries to import a CommonJS module,Module._load
is called withparent
set toundefined
. This results in a crash.To Reproduce
Steps to reproduce the behavior:
camelcase
import("camelcase")
DEBUG='Eleventy:Benchmark*' npx @11ty/eleventy
Expected behavior
No error, ideally helpful timing information is displayed for ES modules in addition to CommonJS ones.
Environment:
Additional context
Ideally, either the
time-require
package would be forked, patched, and updated to work better with ES Modules.As an alternative, it would be great to make the
time-require
import explicitly opt-in, allowing analysis of CJS-only projects without breaking perf debugging for CJS+ESM projects.The text was updated successfully, but these errors were encountered: