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

ES Modules for the configuration file #534

Merged
merged 5 commits into from
Jul 9, 2023
Merged

ES Modules for the configuration file #534

merged 5 commits into from
Jul 9, 2023

Conversation

yhatt
Copy link
Member

@yhatt yhatt commented Jul 9, 2023

Updated cosmiconfig to the latest version, and supported ES Modules in the configuration file.

// marp.config.mjs
export default {
  allowLocalFiles: true,
  html: true,
  engine: ({ marp }) => marp.use(somePlugin)
}

Jest and pkg are not yet supported ES Modules due to the segmentation fault when running dynamic import import(). :(


This PR is also including another improvement for the config: Export Config type to allow better experience while writing a config in IDE. @type JSDoc annotation is available in both of CommonJS and ES Modules.

/** @type {import('@marp-team/marp-cli').Config} */
const config = {
  // ...
}

export default config

If user want to swap the engine from Marp Core, Config type also can provide a suitable type for the swapped engine.

/** @type {import('@marp-team/marp-cli').Config<typeof import('@marp-team/marpit').Marpit>} */
const config = {
  engine: '@marp-team/marpit',
  options: {
    // Only suggests Marpit constructor options, not Marp Core options
  }
}

export default config

@yhatt yhatt merged commit c9bc445 into main Jul 9, 2023
1 check passed
@yhatt yhatt deleted the esm-config branch July 9, 2023 06:50
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

Successfully merging this pull request may close these issues.

1 participant