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: use hyphens for JSR package exports #4424

Merged
merged 3 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
23 changes: 9 additions & 14 deletions _tools/convert_to_workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,16 @@ for (const { specifier, dependencies } of graph.modules) {
const fromPkg = from.split("/")[0];
for (const dep of dependencies ?? []) {
if (dep.code) {
const to = relative(cwd, fromFileUrl(dep.code.specifier)).replaceAll(
"\\",
"/",
);
const to = relative(cwd, fromFileUrl(dep.code.specifier))
.replaceAll("\\", "/");
const toPkg = to.split("/")[0];
if (fromPkg !== toPkg) {
pkgDeps.get(fromPkg)!.add(toPkg);
}
}
if (dep.types) {
const to = relative(cwd, fromFileUrl(dep.types.specifier)).replaceAll(
"\\",
"/",
);
const to = relative(cwd, fromFileUrl(dep.types.specifier))
.replaceAll("\\", "/");
const toPkg = to.split("/")[0];
if (fromPkg !== toPkg) {
pkgDeps.get(fromPkg)!.add(toPkg);
Expand Down Expand Up @@ -182,10 +178,8 @@ for await (const entry of walk(cwd)) {
const target = relative(cwd, path).replaceAll("\\", "/");
const pkg = target.split("/")[0];
if (pkg === currentPkg) {
let newSpecifier = relative(dirname(entry.path), target).replaceAll(
"\\",
"/",
);
let newSpecifier = relative(dirname(entry.path), target)
.replaceAll("\\", "/");
if (!newSpecifier.startsWith(".")) {
newSpecifier = "./" + newSpecifier;
}
Expand Down Expand Up @@ -249,9 +243,10 @@ function fixPackageName(pkg: string) {
function fixPackagePath(path: string) {
const packageName = /^[^/]+/.exec(path);
if (packageName) {
return path.replace(packageName[0], fixPackageName(packageName[0]));
return path.replace(packageName[0], fixPackageName(packageName[0]))
.replaceAll("_", "-");
}
return path;
return path.replaceAll("_", "-");
}

// Generate `deno.json` file.
Expand Down
2 changes: 1 addition & 1 deletion _tools/packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async function discoverExports(pkg: string) {
if (name.includes("/testdata/")) continue; // testdata files
if (name.endsWith("/deno.json")) continue; // deno.json files

const key = "." + name.replace(/\/mod$/, "");
const key = "." + name.replace(/\/mod$/, "").replaceAll("_", "-");
exports.push([key, "." + path]);
}
exports.sort((a, b) => a[0].localeCompare(b[0]));
Expand Down
Loading