Skip to content

Commit

Permalink
feat: add package.json exports (#1922)
Browse files Browse the repository at this point in the history
Closes #1921
  • Loading branch information
dirkdev98 authored Jul 21, 2022
1 parent 841aa6f commit bd71def
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 6 deletions.
5 changes: 4 additions & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"version": "0.0.209",
"description": "CLI containing utilities and simple script runner",
"main": "./index.js",
"exports": "./index.js",
"exports": {
".": "./index.js",
"./package.json": "./package.json"
},
"types": "./index.d.ts",
"type": "module",
"bin": {
Expand Down
5 changes: 4 additions & 1 deletion packages/code-gen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"version": "0.0.209",
"description": "Generate various boring parts of your server",
"main": "./index.js",
"exports": "./index.js",
"exports": {
".": "./index.js",
"./package.json": "./package.json"
},
"types": "./index.d.ts",
"type": "module",
"keywords": [
Expand Down
3 changes: 2 additions & 1 deletion packages/compas/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"./code-gen": "./src/exports/code-gen.js",
"./server": "./src/exports/server.js",
"./stdlib": "./src/exports/stdlib.js",
"./store": "./src/exports/store.js"
"./store": "./src/exports/store.js",
"./package.json": "./package.json"
},
"types": "./index.d.ts",
"type": "module",
Expand Down
6 changes: 6 additions & 0 deletions packages/eslint-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
"version": "0.0.209",
"description": "ESLint plugin",
"main": "index.js",
"exports": {
".": "./index.js",
"./package.json": "./package.json",
"./prettierrc": "./prettierrc.js",
"./prettierrc.js": "./prettierrc.js"
},
"keywords": [
"compas",
"lint",
Expand Down
5 changes: 4 additions & 1 deletion packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"version": "0.0.209",
"description": "Koa server and common middleware",
"main": "./index.js",
"exports": "./index.js",
"exports": {
".": "./index.js",
"./package.json": "./package.json"
},
"types": "./index.d.ts",
"type": "module",
"keywords": [
Expand Down
5 changes: 4 additions & 1 deletion packages/stdlib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"version": "0.0.209",
"description": "All kinds of utility functions",
"main": "./index.js",
"exports": "./index.js",
"exports": {
".": "./index.js",
"./package.json": "./package.json"
},
"types": "./index.d.ts",
"type": "module",
"keywords": [
Expand Down
5 changes: 4 additions & 1 deletion packages/store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"version": "0.0.209",
"description": "Postgres & S3-compatible wrappers for common things",
"main": "./index.js",
"exports": "./index.js",
"exports": {
".": "./index.js",
"./package.json": "./package.json"
},
"types": "./index.d.ts",
"type": "module",
"keywords": [
Expand Down
23 changes: 23 additions & 0 deletions test/repo/package.json.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { readdirSync } from "node:fs";
import { createRequire } from "node:module";
import { mainTestFn, test } from "@compas/cli";

const require = createRequire(import.meta.url);

mainTestFn(import.meta);

test("repo/package.json - imports", (t) => {
for (let pkg of readdirSync("./packages", {
encoding: "utf-8",
})) {
if (pkg !== "compas") {
pkg = `@compas/${pkg}`;
}

const result = require(`${pkg}/package.json`);
t.equal(result.name, pkg, pkg);
t.equal(result.exports?.["./package.json"], "./package.json", pkg);
}

t.pass();
});

0 comments on commit bd71def

Please sign in to comment.