fix: buildVersion now correctly reads from project's package.json #3928
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request addresses an issue where the
BuildVersion
was incorrectly reading from the wrongpackage.json
location. It introduces fixes to ensure theBuildVersion
is accurately derived from the project'spackage.json
and adds comprehensive tests to validate this functionality.#3835
Fixes to
BuildVersion
resolution:.changeset/fix-build-version-package-json.md
: UpdatedgetBuildVersion()
to accept an optionalroot
parameter for correct directory resolution. ModifiedStatsManager
to usecompiler.context
for determining the build version. Ensured thebuildVersion
inmf-manifest.json
matches the project'spackage.json
version.packages/managers/src/utils.ts
: RefactoredgetBuildVersion()
to accept an optionalroot
parameter and use it to read the correctpackage.json
.packages/manifest/src/StatsManager.ts
: UpdatedStatsManager
to use thecontext
from the compiler options when resolving thebuildVersion
. Added a privategetBuildInfo()
method to encapsulate the logic for retrieving build information. [1] [2]Added tests for
BuildVersion
functionality:packages/enhanced/test/configCases/build-version/package-json-version/index.js
: Added a test to verify thatBuildVersion
is correctly read from thepackage.json
and matches the expected version.packages/enhanced/test/configCases/build-version/package-json-version/package.json
: Created a test-specificpackage.json
file with a version of1.2.3
to validate the functionality.packages/enhanced/test/configCases/build-version/package-json-version/webpack.config.js
: Configured a test Webpack setup usingModuleFederationPlugin
to generate themf-manifest.json
for validation.packages/enhanced/test/configCases/build-version/package-json-version/test.js
: Added a simple test module for exposure through the Webpack configuration.