Skip to content

fix(cli): load default exports from JavaScript config - #8593

Open
jabrailkhalil wants to merge 2 commits into
ionic-team:mainfrom
jabrailkhalil:fix/js-config-default-export
Open

jabrailkhalil wants to merge 2 commits into
ionic-team:mainfrom
jabrailkhalil:fix/js-config-default-export

Conversation

@jabrailkhalil

Copy link
Copy Markdown

When capacitor.config.js uses export default, Node returns a module namespace object. The CLI reads settings from that wrapper, so appId and appName become empty and webDir falls back to www.

Unwrap the default export using the same logic as the TypeScript config loader. Add regression tests that run the built config loader in a separate Node process, covering real ES modules and existing CommonJS configurations without Jest transforming the module format.

Fixes #8267.

Validation on Windows, Node 22.21.1:

  • Original source: CommonJS case passes; ES module case fails with empty app identity and webDir: "www".
  • CLI build passes.
  • Config and framework-detection suites: 19 tests pass.
  • ESLint, Prettier, and git diff --check pass.

Native Android/iOS builds and the full platform integration suite were not run.

@jabrailkhalil

Copy link
Copy Markdown
Author

The CI workflows for the current head 08c356893b are waiting for contributor workflow approval (action_required): CI. Could a maintainer approve the pending runs when convenient? These runs have not executed their checks yet; I will address any failures once they run.

riderx pushed a commit to Cap-go/capacitor-plus that referenced this pull request Sep 16, 2026
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.

[Bug]: capacitor.config.js not working

1 participant