fix(bundling): use watch mode for rollup plugin (#26139)

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

## Current Behavior
<!-- This is the behavior we have today -->

`@nx/rollup/plugin` will not properly reload `rollup.config.js` files
when they are updated as they are cached.

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

`@nx/rollup/plugin` loads rollup configs with `watchMode` enabled so
that rollup utilizes the proper cache busting mechanism so that
`rollup.config.js` is properly reloaded.

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
This commit is contained in:
Jason Jean 2024-05-29 09:02:06 -04:00 committed by GitHub
parent bdd3375256
commit 27940d3fff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -94,7 +94,9 @@ async function buildRollupTarget(
const namedInputs = getNamedInputs(projectRoot, context); const namedInputs = getNamedInputs(projectRoot, context);
const rollupConfig = ( const rollupConfig = (
(await loadConfigFile( (await loadConfigFile(
joinPathFragments(context.workspaceRoot, configFilePath) joinPathFragments(context.workspaceRoot, configFilePath),
{},
true // Enable watch mode so that rollup properly reloads config files without reusing a cached version
)) as { options: RollupOptions[] } )) as { options: RollupOptions[] }
).options; ).options;
const outputs = getOutputs(rollupConfig, projectRoot); const outputs = getOutputs(rollupConfig, projectRoot);