Skip to content
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

Add .mjs ES module as supported config type #340

Open
patorpey opened this issue Oct 6, 2021 · 1 comment
Open

Add .mjs ES module as supported config type #340

patorpey opened this issue Oct 6, 2021 · 1 comment

Comments

@patorpey
Copy link

patorpey commented Oct 6, 2021

This is a request to allow the use of ES module files as config files for posthtml through the CLI.

I currently have some build tools that use similar configuration files to posthtml. I have an ES module, config.mjs, that is shared among them to provide build-time string replacements (some computed) for different build flavors. It would be desirable to be able to use this config.mjs from within my posthtml config, as well (such as for use with posthtml-expressions).

Unfortunately, I can't dynamically (asynchronously) import config.mjs from my CJS posthtml.config.js. I tried converting posthtml.config.js to an ES module as well, but even explicitly declaring it with the -c option, the CLI gives:

Error: No loader specified for extension ".mjs"

If posthtml-cli could resolve posthtml.config.mjs, then existing ES modules could be leveraged by configurations using posthtml-cli.

@Scrum
Copy link
Member

Scrum commented Oct 7, 2021

related cosmiconfig/cosmiconfig#224

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants