Skip to content

Commit

Permalink
Fix generated .pnp.js compatibility with Node 6.
Browse files Browse the repository at this point in the history
Prior to these changes the generated `.pnp.js` file would use trailing
commas for function invocations which is not allowed (and generates a
parse error) under Node 6.

This removes the offending trailing commas...
  • Loading branch information
rwjblue committed Jan 3, 2019
1 parent d7811e4 commit 32c8a19
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/util/generate-pnp-map-api.tpl.js
Expand Up @@ -82,7 +82,7 @@ function blacklistCheck(locator) {
`A package has been resolved through a blacklisted path - this is usually caused by one of your tools calling`,
`"realpath" on the return value of "require.resolve". Since the returned values use symlinks to disambiguate`,
`peer dependencies, they must be passed untransformed to "require".`,
].join(` `),
].join(` `)
);
}

Expand Down Expand Up @@ -116,7 +116,7 @@ function getPackageInformationSafe(packageLocator) {
if (!packageInformation) {
throw makeError(
`INTERNAL`,
`Couldn't find a matching entry in the dependency tree for the specified parent (this is probably an internal error)`,
`Couldn't find a matching entry in the dependency tree for the specified parent (this is probably an internal error)`
);
}

Expand Down Expand Up @@ -348,7 +348,7 @@ exports.resolveToUnqualified = function resolveToUnqualified(request, issuer, {c
{
request,
issuer,
},
}
);
}

Expand Down Expand Up @@ -392,7 +392,7 @@ exports.resolveToUnqualified = function resolveToUnqualified(request, issuer, {c
{
request,
issuer,
},
}
);
}

Expand Down Expand Up @@ -424,30 +424,30 @@ exports.resolveToUnqualified = function resolveToUnqualified(request, issuer, {c
throw makeError(
`MISSING_PEER_DEPENDENCY`,
`You seem to be requiring a peer dependency ("${dependencyName}"), but it is not installed (which might be because you're the top-level package)`,
{request, issuer, dependencyName},
{request, issuer, dependencyName}
);
} else {
throw makeError(
`MISSING_PEER_DEPENDENCY`,
`Package "${issuerLocator.name}@${issuerLocator.reference}" is trying to access a peer dependency ("${dependencyName}") that should be provided by its direct ancestor but isn't`,
{request, issuer, issuerLocator: Object.assign({}, issuerLocator), dependencyName},
{request, issuer, issuerLocator: Object.assign({}, issuerLocator), dependencyName}
);
}
} else {
if (issuerLocator === topLevelLocator) {
throw makeError(
`UNDECLARED_DEPENDENCY`,
`You cannot require a package ("${dependencyName}") that is not declared in your dependencies (via "${issuer}")`,
{request, issuer, dependencyName},
{request, issuer, dependencyName}
);
} else {
const candidates = Array.from(issuerInformation.packageDependencies.keys());
throw makeError(
`UNDECLARED_DEPENDENCY`,
`Package "${issuerLocator.name}@${issuerLocator.reference}" (via "${issuer}") is trying to require the package "${dependencyName}" (via "${request}") without it being listed in its dependencies (${candidates.join(
`, `,
`, `
)})`,
{request, issuer, issuerLocator: Object.assign({}, issuerLocator), dependencyName, candidates},
{request, issuer, issuerLocator: Object.assign({}, issuerLocator), dependencyName, candidates}
);
}
}
Expand All @@ -463,7 +463,7 @@ exports.resolveToUnqualified = function resolveToUnqualified(request, issuer, {c
throw makeError(
`MISSING_DEPENDENCY`,
`Package "${dependencyLocator.name}@${dependencyLocator.reference}" is a valid dependency, but hasn't been installed and thus cannot be required (it might be caused if you install a partial tree, such as on production environments)`,
{request, issuer, dependencyLocator: Object.assign({}, dependencyLocator)},
{request, issuer, dependencyLocator: Object.assign({}, dependencyLocator)}
);
}

Expand Down Expand Up @@ -496,7 +496,7 @@ exports.resolveUnqualified = function resolveUnqualified(
throw makeError(
`QUALIFIED_PATH_RESOLUTION_FAILED`,
`Couldn't find a suitable Node resolution for unqualified path "${unqualifiedPath}"`,
{unqualifiedPath},
{unqualifiedPath}
);
}
};
Expand Down Expand Up @@ -550,7 +550,7 @@ exports.resolveRequest = function resolveRequest(request, issuer, {considerBuilt
request,
issuer,
realIssuer,
},
}
);
}
}
Expand Down Expand Up @@ -673,7 +673,7 @@ exports.setup = function setup() {
if (optionNames.size > 0) {
throw makeError(
`UNSUPPORTED`,
`Some options passed to require() aren't supported by PnP yet (${Array.from(optionNames).join(', ')})`,
`Some options passed to require() aren't supported by PnP yet (${Array.from(optionNames).join(', ')})`
);
}

Expand Down

0 comments on commit 32c8a19

Please sign in to comment.