Skip to content

Commit

Permalink
chore(cli): update error message (#2571)
Browse files Browse the repository at this point in the history
This change updates the error message produced by the native replacement
package to make it clear that native modules are not currently
supported.  This change also includes two small fixes suggested by
sonarqube.

Signed-off-by: Stan Lewis <[email protected]>
  • Loading branch information
gashcrumb authored Dec 4, 2024
1 parent 2acb6e0 commit 99d3145
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .changeset/grumpy-bulldogs-sit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ ${
path.join(target, 'embedded', toSuppress, 'index.js'),
`
throw new Error(
'The package "${toSuppress}" has been marked as a native module and removed from this dynamic plugin package "${derivedPackageName}"'
'The package "${toSuppress}" has been marked as a native module and removed from this dynamic plugin package "${derivedPackageName}", as native modules are not currently supported by dynamic plugins'
);`,
);
}
Expand Down Expand Up @@ -233,11 +233,15 @@ throw new Error(
})(path.join(embeddedDestDir, 'package.json'));
}

const embeddedDependenciesResolutions: { [key: string]: any } = {};
embeddedResolvedPackages.map(ep => {
embeddedDependenciesResolutions[ep.packageName] =
`file:./${embeddedPackageRelativePath(ep)}`;
});
const embeddedDependenciesResolutions = embeddedResolvedPackages.reduce(
(resolutions, embeddedPkg) => ({
...resolutions,
...{
[embeddedPkg.packageName]: `file:./${embeddedPackageRelativePath(embeddedPkg)}`,
},
}),
{},
);

if (opts.build) {
Task.log(`Building main package`);
Expand Down
18 changes: 9 additions & 9 deletions packages/cli/src/commands/export-dynamic-plugin/backend-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,16 @@ export function addToMainDependencies(
Task.log(
`The version of a dependency ('${dep}') of an embedded module differs from the main module's dependencies: '${dependenciesToAdd[dep]}', '${existingVersion}': keeping it as it is compatible`,
);
continue;
}
if (ignoreVersionCheck.includes(dep)) {
Task.log(
`The version of a dependency ('${dep}') of an embedded module conflicts with the main module's dependencies: '${dependenciesToAdd[dep]}', '${existingVersion}': however this has been overridden`,
);
} else {
if (!ignoreVersionCheck.includes(dep)) {
throw new Error(
`The version of a dependency ('${dep}') of an embedded module conflicts with main module dependencies: '${dependenciesToAdd[dep]}', '${existingVersion}': cannot proceed!`,
);
} else {
Task.log(
`The version of a dependency ('${dep}') of an embedded module conflicts with the main module's dependencies: '${dependenciesToAdd[dep]}', '${existingVersion}': however this has been overridden`,
);
}
throw new Error(
`The version of a dependency ('${dep}') of an embedded module conflicts with main module dependencies: '${dependenciesToAdd[dep]}', '${existingVersion}': cannot proceed!`,
);
}
}
}
Expand Down

0 comments on commit 99d3145

Please sign in to comment.