-
Notifications
You must be signed in to change notification settings - Fork 712
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
Support plugins that execute as native ESM #1635
Comments
This would be a breaking change, since plugins are loaded in |
Ok, I think the require-then-import approach could be used to keep
bootstrap sync if wanted to preserve backwards-compat, and then a new
bootstrapAsync could be added which supports ESM plugins. I suppose
attempting to use any async plugin via the old bootstrap API would throw an
error.
Not sure if the above is feasible of worthwhile, or if it's better to keep
it simple and do the breaking change.
…On Sun, Jul 18, 2021, 9:48 AM Gerrit Birkeland ***@***.***> wrote:
This would be a breaking change, since plugins are loaded in
Application.bootstrap which is currently not async, but it seems like a
reasonable approach to me.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1635 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAC35OBH76GNW3JYKUOS653TYLLRLANCNFSM5AR232AA>
.
|
I like keeping it simple, this is a pretty minor breaking change. |
So... I looked at doing this, and it's not something that I want to commit to in 0.22. I'm fine with the breaking change, but it seems that doing this properly either requires turning on allowJs so that TS doesn't transpile the import into If someone wants to use ESM plugins badly enough, and sends a PR, I'll definitely look at it, but this isn't as straightforward as I thought at first. |
I've accomplished this by shipping a single, non-transpiled JS file. It
shouldn't require allowJs.
I put in it `exports.importHelper = function(specifier) {return
import(specifier)}` and then use it wherever I need a non-transpiled
dynamic import().
…On Fri, Aug 20, 2021, 12:22 AM Gerrit Birkeland ***@***.***> wrote:
So... I looked at doing this, and it's not something that I want to commit
to in 0.22. I'm fine with the breaking change, but it seems that doing this
properly either requires turning on allowJs so that TS doesn't transpile
the import into Promise.resolve().then(() => require(...)) (ew), adding a
dependency (double ew), or switching to emitting ESM (which is a rats nest
that I don't want to get into right now)
If someone wants to use ESM plugins badly enough, and sends a PR, I'll
definitely look at it, but this isn't as straightforward as I thought at
first.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1635 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAC35OFCO6QNXQ4EK7MQCBTT5XJ77ANCNFSM5AR232AA>
.
|
Search Terms
native ecmascript, esm, plugin
Problem
It would be nice to write TypeDoc plugins as ESM modules, using node's new native ESM support
Suggested Solution
typedoc can first try to
require()
the plugin, then if it gets anERR_REQUIRE_ESM
error, it canimport()
it instead. This will support both CJS and ESM and will also support CJS transpilers like ts-node. I'm not sure if the ts-node use-case is meant to be supported or not. If not, typedoc can merelyimport()
the plugins.import()
is async; I don't know if typedoc's plugin loading can be async.The text was updated successfully, but these errors were encountered: