Skip to content

Add .mjs ES module as supported config type #340

@patorpey

Description

@patorpey

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions