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

unbuild loads config in cjs context #92

Closed
danielroe opened this issue Jul 18, 2022 · 2 comments
Closed

unbuild loads config in cjs context #92

danielroe opened this issue Jul 18, 2022 · 2 comments

Comments

@danielroe
Copy link
Member

const _require = jiti(ctx.options.rootDir, options.jiti)
const distDir = entry.outDir!
const srcConfig = _require(resolve(ctx.options.rootDir, entry.input))

Because jiti runs in an CJS context, although transpiled, ESM-only modules can't be loaded within unbuild's build.config (even if it is named build.config.mjs).

Would there be any merit in moving unbuild to use c12 and resolving this there?

Related: unjs/jiti#32.

@pi0
Copy link
Member

pi0 commented Jul 18, 2022

Indeed would be good idea to use c12/jiti stack but as you pointed it is still cjs. Issue with cjs and it will resolve only for mjs (ts would have same issues)

Issue with estree-walker is resolved in jiti but had to move it behind esmResolve flag due to regressions. We might enable that flag by default when loading config.

@pi0
Copy link
Member

pi0 commented Jul 20, 2022

#94

@pi0 pi0 closed this as completed Jul 20, 2022
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

No branches or pull requests

2 participants