Skip to content

Support alternate parsersΒ #1444

@noahw3

Description

@noahw3

Is there an existing issue that is already proposing this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe it

Currently the default parser, dotenv, fails to correctly parse my config file. In particular, it does not support parsing escaped JSON (see motdotla/dotenv#771).

I'm using projen to create the file, which uses the ini library to do so. However, the output files that it creates are not always directly compatible with dotenv as a parser.

The ini parser also supports writing objects as section headers, and then supports parsing them back as well. This is potentially nice functionality to support as well.

Describe the solution you'd like

A new option on ConfigModuleOptions to specify the parser. The default would be the current dotenv parser, but the ini parser would be another option. If necessary, further parser options could be added in the future.

Alternatively, the config option could be the parser function itself. This would enable a BYO parser approach, and not require this library to add any extra dependencies

As far as I can tell, the variable expansion behavior can continue working as is using dotenv-expand without any issue.

Teachability, documentation, adoption, migration strategy

It should be relatively straightforward to add a section to the docs explaining the parser options, and reasons why the ini parser may be preferred over the dotenv parser.

What is the motivation / use case for changing the behavior?

See the problem section above.

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