Skip to content

barrel preset, adding extension for support ESM modules #12

@zanza00

Description

@zanza00

One of the requirements of ESM modules is that every import need an extension (see here).

Since it depends on the build toolchain on exactly what extension to use, it can be anyone of the followings js, mjs, cjs, ts, mts and cts.

I suggest adding a specific option called extension that is appended to the import, using the example in the readme it will be modified as follows

// codegen:start {preset: barrel, include: some/path/*.ts, exclude: some/path/*util.ts, extension: mjs}
export * from './some/path/module-a.mjs'
export * from './some/path/module-b.mjs'
export * from './some/path/module-c.mjs'
// codegen:end

I glanced the code and I think I can create a PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions