Skip to content

Commit 1acf3a1

Browse files
authored
Aiinfo diffcache (#103)
* add changelog to output * add clearCache utility * update cache * add writeChangelog util * ignore package.json in biome lint * @instructure.ai/aiinfo@1.1.2 * fix lint issues * @instructure.ai/aiinfo@1.2.0 * use vite-node/loader * aiinfo@1.2.1 * use loader as an export * aiinfo@1.2.2 * use custom loader * aiinfo@1.2.3 * quote loader * use correct path * aiinfo@1.2.4 * proper quotes * use nextLoad
1 parent 020df30 commit 1acf3a1

3 files changed

Lines changed: 35 additions & 2 deletions

File tree

.github/workflows/release-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
pnpm install --frozen-lockfile
5959
6060
# NOW enable vite-node loader so any .ts/.mts imports work everywhere below
61-
export NODE_OPTIONS="--loader=$(pwd)/node_modules/vite-node/loader"
61+
export NODE_OPTIONS="--loader=${{ github.workspace }}/scripts/loader.mjs"
6262
6363
# Build
6464
if [ "$PKG_NAME" = "shared-configs" ]; then

packages/aiinfo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,5 @@
4747
"sideEffects": false,
4848
"type": "module",
4949
"types": "./dist/index.d.ts",
50-
"version": "1.2.2"
50+
"version": "1.2.4"
5151
}

scripts/loader.mjs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { readFile } from "node:fs/promises";
2+
import { extname } from "node:path";
3+
import { fileURLToPath } from "node:url";
4+
import { transformWithEsbuild } from "vite";
5+
6+
const mtsExtensions = new Set([".ts", ".mts", ".cts", ".tsx"]);
7+
8+
9+
export async function resolve(specifier, context, nextResolve) {
10+
const resolved = await nextResolve(specifier, context, nextResolve);
11+
return resolved;
12+
}
13+
14+
15+
export async function load(url, context, nextLoad) {
16+
const extension = extname(url);
17+
if (mtsExtensions.has(extension)) {
18+
const filename = fileURLToPath(url);
19+
const source = await readFile(filename, "utf8");
20+
const result = await transformWithEsbuild(source, filename, {
21+
format: "esm",
22+
loader: extension === ".tsx" ? "tsx" : "ts",
23+
sourcemap: "inline",
24+
});
25+
return {
26+
format: "module",
27+
shortCircuit: true,
28+
source: result.code,
29+
};
30+
}
31+
32+
return nextLoad(url, context, nextLoad);
33+
}

0 commit comments

Comments
 (0)