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

fix: remove overly strict checks on peer versions #306

Merged
merged 1 commit into from
Nov 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions packages/jsii/lib/assembler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,7 @@ function _sortMembers(type: spec.ClassType | spec.InterfaceType): spec.ClassTyp

function _toDependencies(assemblies: ReadonlyArray<spec.Assembly>, peers: ReadonlyArray<spec.Assembly>): { [name: string]: spec.PackageVersion } {
const result: { [name: string]: spec.PackageVersion } = {};

for (const assembly of assemblies) {
result[assembly.name] = {
version: assembly.version,
Expand All @@ -1094,16 +1095,6 @@ function _toDependencies(assemblies: ReadonlyArray<spec.Assembly>, peers: Readon
}

for (const peer of peers) {
if (peer.name in result) {
// module already appears as a normal dependency. just make sure it's the same version
const depVersion = result[peer.name].version;
if (depVersion !== peer.version) {
throw new Error(
`Module '${peer.name}' appears both as a dependency (${depVersion}) ` +
`and a peer dependency (${peer.version}), with mismatching versions`);
}
}

result[peer.name] = {
version: peer.version,
targets: peer.targets,
Expand Down
18 changes: 5 additions & 13 deletions packages/jsii/lib/project-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,13 @@ export async function loadProjectInfo(projectRoot: string): Promise<ProjectInfo>
if (!version) {
throw new Error(`The "package.json" has "${name}" in "bundleDependencies", but it is not declared in "dependencies"`);
}
bundleDependencies[name] = version;
});

// verify peer dependencies and dependencies have the same version specs
const deps = pkg.dependencies || { };
const peerDeps = pkg.peerDependencies || { };
for (const module of Object.keys(peerDeps)) {
const peerVersion = peerDeps[module];
const depVersion = deps[module];
if (depVersion && peerVersion !== depVersion) {
throw new Error(
`The module '${module}' is specified as ${peerVersion} under ` +
`"peerDependencieds" and as ${depVersion} under "dependencies"`);
if (pkg.peerDependencies && name in pkg.peerDependencies) {
throw new Error(`The "package.json" has "${name}" in "bundleDependencies", and also in "peerDependencies"`);
}
}

bundleDependencies[name] = version;
});

const transitiveAssemblies: { [name: string]: spec.Assembly } = {};
const dependencies =
Expand Down