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

feat(devkit): add loadConfigFile function for plugins to use #21511

Merged
merged 1 commit into from
Feb 2, 2024

Conversation

jaysoo
Copy link
Member

@jaysoo jaysoo commented Feb 2, 2024

This PR adds loadConfigFile function to @nx/devkit so plugins can use it to read config files in both CJS and ESM format. TS config files are handled as well.

We try to load via require first, which should be faster and has better cache busting guarantees. If that fails, then we try to load using import() because it is likely ESM.

The ESM case should only happen when either:

  1. The file ends with .mjs
  2. The file ends with .ts or .js and package.json specifies "type": "module"

By default (1) would be used for Nx workspaces, however repos like epic-stack uses ESM.

Current Behavior

Sometimes cache is not busted using import().

Expected Behavior

Prefer require for better cache busting, but fallback to import() which should work as well with ?t=.... appended.

@jaysoo jaysoo requested review from a team and Coly010 as code owners February 2, 2024 00:49
Copy link

vercel bot commented Feb 2, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Updated (UTC)
nx-dev ⬜️ Ignored (Inspect) Visit Preview Feb 2, 2024 3:22am

@jaysoo jaysoo force-pushed the config_cache_bust branch 3 times, most recently from b53117d to 591827d Compare February 2, 2024 02:24
@jaysoo jaysoo changed the title feat(devkit): add loadConfigFile function that busts import cache feat(devkit): add loadConfigFile function for plugins to use Feb 2, 2024
@FrozenPandaz FrozenPandaz enabled auto-merge (squash) February 2, 2024 03:24
@FrozenPandaz FrozenPandaz merged commit 05b0848 into nrwl:master Feb 2, 2024
5 of 6 checks passed
@jaysoo jaysoo deleted the config_cache_bust branch February 2, 2024 04:25
Copy link

github-actions bot commented Feb 9, 2024

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants