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

ESM support for config file #326

Open
trusktr opened this issue Feb 7, 2021 · 3 comments
Open

ESM support for config file #326

trusktr opened this issue Feb 7, 2021 · 3 comments
Assignees
Labels
Breaking Change 💥 An API Is Going to Change Docs 📜 Something related to the docs Enhancement 🌴 New feature or request Help Wanted ✋ Extra attention is needed Question ❔ Further information is requested Waiting 🛑 Something is waiting

Comments

@trusktr
Copy link
Contributor

trusktr commented Feb 7, 2021

https://github.com/jtenner/as-pect/blob/4736a6aeb4ddad677d1258133686e3a290e88ce2/packages/cli/src/run.ts#L158

Would be nice to either call require or import there based on some conditions. I haven't implemented something for that before, but I imagine this:

  • if the config ends with .cjs, use require
  • if it ends with .mjs, use import
  • for plain .js,
    • If asp is running in a project with type:module, then use import
    • If asp is not running in a project with type:module, use require
@trusktr
Copy link
Contributor Author

trusktr commented Feb 7, 2021

An alternative could be to allow aspect's config file to export a promise or an async function, then even if it is CJS the user can still await import() for anything and use ESM in their dependency tree that the config imports.

@jtenner
Copy link
Contributor

jtenner commented Feb 10, 2021

@willemneal this is a great idea. WDYT?

@jtenner
Copy link
Contributor

jtenner commented Mar 1, 2021

I think we should keep as-pect as it is until the CLI rewrite.

@jtenner jtenner self-assigned this Mar 1, 2021
@jtenner jtenner added Breaking Change 💥 An API Is Going to Change Docs 📜 Something related to the docs Enhancement 🌴 New feature or request Help Wanted ✋ Extra attention is needed Question ❔ Further information is requested Waiting 🛑 Something is waiting labels Mar 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaking Change 💥 An API Is Going to Change Docs 📜 Something related to the docs Enhancement 🌴 New feature or request Help Wanted ✋ Extra attention is needed Question ❔ Further information is requested Waiting 🛑 Something is waiting
Projects
None yet
Development

No branches or pull requests

2 participants