-
Notifications
You must be signed in to change notification settings - Fork 644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Node esm loader support #1728
Node esm loader support #1728
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1728 +/- ##
==========================================
- Coverage 90.31% 90.29% -0.03%
==========================================
Files 224 224
Lines 6828 6819 -9
==========================================
- Hits 6167 6157 -10
- Misses 661 662 +1 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just taking a peek at Marko internals/activity, spotted this PR, and wanted to give a heads up about this API change.
packages/compiler/loader.mjs
Outdated
export function getFormat(url, context, defaultGetFormat) { | ||
return extensionRegex.test(url) | ||
? format | ||
: defaultGetFormat(url, context, defaultGetFormat); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heads up that the loader hooks API has changed in LTS 16.12.0+ along with 17.x, which will presumably provide the initial API for 18.x. The change eliminates getFormat
, moving its responsibility to the two remaining functions1:
resolve
, as a hintload
, which can use that hint but has the final say
You'll likely want to call this in resolve
(assuming you need to support 14.x), with the fallback deferring to the result from defaultResolve
.
Footnotes
-
besides
globalPreload
, which is intended for setup not the dynamic runtime ↩
c5aab6f
to
8610afb
Compare
Marking as blocked because:
|
Note this will still probably happen because sometimes computers are terrible, but likely with a disclaimer about using it (and the |
Description
Resolves #1727
Adds support for loading Marko files directly as ESM via a node ESM Loader hook.
This means you can run node like
And importing Marko files will work as is.
Primarily this PR contains two main changes.
loader.mjs
file to the compiler package.imports
added when compiling a Marko template to have the filename (including extension) to be more native esm friendly.Checklist: