Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Elmer Bulthuis committed Mar 8, 2024
1 parent a6988f7 commit 31d269a
Show file tree
Hide file tree
Showing 10 changed files with 279 additions and 25 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

node_modules/
target/
transpiled/
types/
bundled/
out/
out-*/
coverage/
obj/
bin/
Expand Down
209 changes: 209 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions packages/npm/goodrouter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,26 @@
"version": "2.1.4",
"description": "a good router",
"type": "module",
"main": "./out-commonjs/main.js",
"module": "./out/main.js",
"types": "./out/main.d.ts",
"main": "./bundled/main.cjs",
"module": "./bundled/main.js",
"types": "./types/main.d.ts",
"exports": {
".": {
"require": "./out-commonjs/main.js",
"import": "./out/main.js",
"types": "./out/main.d.ts",
"browser": "./out/browser.js"
"require": "./bundled/main.cjs",
"import": "./bundled/main.js",
"types": "./types/main.d.ts"
}
},
"files": [
"./out/**",
"./out-commonjs/**"
"./types/**",
"./bundled/**"
],
"scripts": {
"prepack": "tsc --composite false; tsc --composite false --outDir out-commonjs --declaration false --module commonjs --moduleResolution Node10 ; echo {\\\"type\\\":\\\"commonjs\\\"}> out-commonjs/package.json",
"prepack": "./scripts/build.js",
"pretest": "tsc --build",
"build": "tsc --build",
"clean": "rm -rf out out-* ; tsc --build --clean",
"test": "node --test ./out/**/*.test.js"
"clean": "./scripts/clean.js",
"test": "node --test ./out/*.test.js ./out/*/*.test.js ./out/*/*/*.test.js"
},
"repository": {
"type": "git",
Expand All @@ -48,6 +47,7 @@
"itertools": "^2.2.5",
"microtime": "^3.1.1",
"prettier": "^3.2.5",
"rollup": "^4.12.1",
"typescript": "^5.4.2"
},
"dependencies": {
Expand Down
34 changes: 34 additions & 0 deletions packages/npm/goodrouter/scripts/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env node

import cp from "child_process";
import path from "path";

cp.spawnSync("tsc", [], { stdio: "inherit" });

cp.spawnSync(
"rollup",
[
"--input",
path.resolve("transpiled", "main.js"),
"--file",
path.resolve("bundled", "main.js"),
"--sourcemap",
"--format",
"es",
],
{ stdio: "inherit" },
);

cp.spawnSync(
"rollup",
[
"--input",
path.resolve("transpiled", "main.js"),
"--file",
path.resolve("bundled", "main.cjs"),
"--sourcemap",
"--format",
"cjs",
],
{ stdio: "inherit" },
);
8 changes: 8 additions & 0 deletions packages/npm/goodrouter/scripts/clean.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env node

import fs from "fs";
import path from "path";

fs.rmSync(path.resolve("transpiled"), { recursive: true, force: true });
fs.rmSync(path.resolve("types"), { recursive: true, force: true });
fs.rmSync(path.resolve("bundled"), { recursive: true, force: true });
8 changes: 8 additions & 0 deletions packages/npm/goodrouter/src/root.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import path from "path";

export const projectRoot = getProjectRoot();

function getProjectRoot() {
const dirname = import.meta.dirname ?? __dirname;
return path.resolve(dirname, "..");
}
2 changes: 1 addition & 1 deletion packages/npm/goodrouter/src/testing/templates.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as fs from "fs";
import * as path from "path";
import { projectRoot } from "../utils/root.js";
import { projectRoot } from "../root.js";

export function loadTemplates(name: string) {
const filePath = path.join(
Expand Down
9 changes: 0 additions & 9 deletions packages/npm/goodrouter/src/utils/root.ts

This file was deleted.

5 changes: 3 additions & 2 deletions packages/npm/goodrouter/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
"extends": "@tsconfig/node20",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./out",
"outDir": "./transpiled",
"declarationDir": "./types",
"sourceMap": true,
"declaration": true,
"composite": true
"lib": ["es2023", "DOM"]
},
"include": ["src/**/*"]
}
1 change: 1 addition & 0 deletions packages/npm/www/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"@11ty/eleventy": "^2.0.1",
"github-markdown-css": "^5.5.1",
"prettier": "^3.2.5",
"rollup": "^4.12.1",
"typescript": "^5.4.2"
}
}

0 comments on commit 31d269a

Please sign in to comment.