From d45280100cd5cfb4d1be11e6d348f40ffd1b2698 Mon Sep 17 00:00:00 2001 From: Pass Automated Testing Suite Date: Fri, 23 Aug 2024 16:04:18 -0400 Subject: [PATCH] use Node 16 module resolution --- docs/akte.app.ts | 4 ++-- docs/akte/markdownToHTML.ts | 10 +++------- docs/files/pages.ts | 4 ++-- docs/tsconfig.json | 8 ++++---- docs/vite.config.ts | 2 +- package-lock.json | 9 +++++---- playground/akte.app.ts | 8 ++++---- playground/src/pages/catchAll/index.ts | 4 ++-- playground/src/pages/index.ts | 4 ++-- playground/src/pages/posts/slug.ts | 2 +- playground/vite.config.ts | 2 +- src/AkteApp.ts | 22 +++++++++++----------- src/AkteFiles.ts | 12 ++++++------ src/akteWelcome.ts | 6 +++--- src/defineAkteApp.ts | 2 +- src/defineAkteFile.ts | 4 ++-- src/defineAkteFiles.ts | 4 ++-- src/errors.ts | 18 +++++++++++------- src/index.ts | 12 ++++++------ src/lib/createDebugger.ts | 4 ++-- src/lib/hasFlag.ts | 2 +- src/lib/pathToRouterPath.ts | 2 +- src/runCLI.ts | 10 +++++----- src/vite/AkteViteCache.ts | 6 +++--- src/vite/aktePlugin.ts | 8 ++++---- src/vite/createAkteViteCache.ts | 2 +- src/vite/index.ts | 4 ++-- src/vite/plugins/buildPlugin.ts | 8 ++++---- src/vite/plugins/serverPlugin.ts | 10 +++++----- src/vite/types.ts | 2 +- test/AkteApp-buildAll.test.ts | 12 ++++++------ test/AkteApp-getGlobalData.test.ts | 12 ++++++------ test/AkteApp-getRouter.test.ts | 12 ++++++------ test/AkteApp-lookup.test.ts | 12 ++++++------ test/AkteApp-render.test.ts | 14 +++++++------- test/AkteApp-renderAll.test.ts | 16 ++++++++-------- test/AkteApp-writeAll.test.ts | 12 ++++++------ test/AkteFile-getBulkData.test.ts | 2 +- test/AkteFile-getData.test.ts | 2 +- test/__fixtures__/about.ts | 2 +- test/__fixtures__/index.ts | 2 +- test/__fixtures__/jsons.ts | 2 +- test/__fixtures__/noGlobalData.ts | 2 +- test/__fixtures__/pages.ts | 2 +- test/__fixtures__/posts.ts | 2 +- test/__fixtures__/renderError.ts | 2 +- test/defineAkteApp.test-d.ts | 2 +- test/defineAkteFile.test-d.ts | 2 +- test/defineAkteFiles.test-d.ts | 2 +- test/index.test.ts | 2 +- test/runCLI.test.ts | 14 +++++++------- tsconfig.json | 8 ++++---- vite.config.ts | 2 +- 53 files changed, 168 insertions(+), 167 deletions(-) diff --git a/docs/akte.app.ts b/docs/akte.app.ts index f4425a6..5d6b346 100644 --- a/docs/akte.app.ts +++ b/docs/akte.app.ts @@ -2,8 +2,8 @@ import { defineAkteApp } from "akte"; import { version } from "../package.json"; -import { pages } from "./files/pages"; -import { sitemap } from "./files/sitemap"; +import { pages } from "./files/pages.js"; +import { sitemap } from "./files/sitemap.js"; export const app = defineAkteApp({ files: [pages, sitemap], diff --git a/docs/akte/markdownToHTML.ts b/docs/akte/markdownToHTML.ts index 8f9275b..6dc515e 100644 --- a/docs/akte/markdownToHTML.ts +++ b/docs/akte/markdownToHTML.ts @@ -1,4 +1,4 @@ -import { type Plugin, type Processor, unified } from "unified"; +import { type Plugin, type Processor, unified, } from "unified"; import remarkParse from "remark-parse"; import remarkGfm from "remark-gfm"; @@ -10,15 +10,11 @@ import remarkRehype from "remark-rehype"; import rehypeSlug from "rehype-slug"; import rehypeAutolinkHeadings from "rehype-autolink-headings"; -import rehypeToc from "rehype-toc"; +import rehypeToc, { type Options as RehypeTocOptions } from "rehype-toc"; import rehypeStringify from "rehype-stringify"; import { common, createStarryNight } from "@wooorm/starry-night"; - -// @ts-expect-error - Cannot resolve type import ignoreGrammar from "@wooorm/starry-night/source.gitignore"; - -// @ts-expect-error - Cannot resolve type import tsxGrammar from "@wooorm/starry-night/source.tsx"; import { visit } from "unist-util-visit"; import { toString } from "hast-util-to-string"; @@ -177,7 +173,7 @@ export const markdownToHTML = async >( .use(rehypeSlug) .use(rehypeAutolinkHeadings, { behavior: "wrap" }) - .use(rehypeToc, { + .use(rehypeToc as unknown as Plugin<[RehypeTocOptions]>, { headings: ["h2", "h3"], cssClasses: { list: "", diff --git a/docs/files/pages.ts b/docs/files/pages.ts index c5d131d..f6152a3 100644 --- a/docs/files/pages.ts +++ b/docs/files/pages.ts @@ -4,8 +4,8 @@ import * as fs from "node:fs/promises"; import { defineAkteFiles } from "akte"; import { globby } from "globby"; -import { markdownToHTML } from "../akte/markdownToHTML"; -import { base } from "../layouts/base"; +import { markdownToHTML } from "../akte/markdownToHTML.js"; +import { base } from "../layouts/base.js"; const contentDir = path.resolve(__dirname, "../content"); diff --git a/docs/tsconfig.json b/docs/tsconfig.json index 393e207..2028194 100644 --- a/docs/tsconfig.json +++ b/docs/tsconfig.json @@ -3,17 +3,17 @@ "strict": true, "skipLibCheck": true, - "target": "esnext", - "module": "esnext", + "target": "ES2022", + "module": "Node16", "declaration": false, - "moduleResolution": "node", + "moduleResolution": "Node16", "resolveJsonModule": true, "allowSyntheticDefaultImports": true, "esModuleInterop": true, "forceConsistentCasingInFileNames": true, "jsx": "preserve", - "lib": ["esnext", "dom"], + "lib": ["ES2023", "DOM"], "types": ["node"] }, "exclude": ["node_modules", "dist", "examples"] diff --git a/docs/vite.config.ts b/docs/vite.config.ts index b6f8955..642aa77 100644 --- a/docs/vite.config.ts +++ b/docs/vite.config.ts @@ -1,7 +1,7 @@ import { defineConfig } from "vite"; import akte from "akte/vite"; -import { app } from "./akte.app"; +import { app } from "./akte.app.js"; export default defineConfig({ build: { diff --git a/package-lock.json b/package-lock.json index aaa8b6f..f7dd08f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -94,10 +94,11 @@ } }, "docs/node_modules/akte": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/akte/-/akte-0.4.0.tgz", - "integrity": "sha512-MjmEg8uKK2gGKgGM5cTkzf6lY3W2thROaZ/ivBd5a2NlsS0zhv4qCmkqEUMGjNr+Rd3atjoSLZkoPAZ9i/Yrzg==", + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/akte/-/akte-0.4.2.tgz", + "integrity": "sha512-9POFlm16Vigc3wgUu6KHzCCo0ojbdRQ377DL81vzhBObFN1CCDH71Tgn5AeZXvhuu+MpIZajjSbZQWeyOU1B+A==", "dev": true, + "license": "MIT", "workspaces": [ ".", "docs", @@ -107,7 +108,7 @@ "dependencies": { "debug": "^4.3.4", "http-proxy": "^1.18.1", - "radix3": "^1.1.0" + "radix3": "^1.1.2" }, "engines": { "node": ">=16.13.0" diff --git a/playground/akte.app.ts b/playground/akte.app.ts index 10650cf..bdc41e8 100644 --- a/playground/akte.app.ts +++ b/playground/akte.app.ts @@ -1,9 +1,9 @@ import { defineAkteApp } from "akte"; -import { index } from "./src/pages/index"; -import { sitemap } from "./src/pages/sitemap"; -import { postsSlug } from "./src/pages/posts/slug"; -import { catchAll } from "./src/pages/catchAll"; +import { index } from "./src/pages/index.js"; +import { sitemap } from "./src/pages/sitemap.js"; +import { postsSlug } from "./src/pages/posts/slug.js"; +import { catchAll } from "./src/pages/catchAll/index.js"; export const app = defineAkteApp({ // files: [], diff --git a/playground/src/pages/catchAll/index.ts b/playground/src/pages/catchAll/index.ts index b9e9978..77aa3a5 100644 --- a/playground/src/pages/catchAll/index.ts +++ b/playground/src/pages/catchAll/index.ts @@ -1,7 +1,7 @@ import { defineAkteFiles } from "akte"; -import { basic } from "../../layouts/basic"; +import { basic } from "../../layouts/basic.js"; -export const catchAll = defineAkteFiles().from({ +export const catchAll = defineAkteFiles().from({ path: "/catch-all/**", bulkData() { return { diff --git a/playground/src/pages/index.ts b/playground/src/pages/index.ts index 0da0434..382b2d6 100644 --- a/playground/src/pages/index.ts +++ b/playground/src/pages/index.ts @@ -1,7 +1,7 @@ import { defineAkteFile } from "akte"; -import { basic } from "../layouts/basic"; +import { basic } from "../layouts/basic.js"; -export const index = defineAkteFile().from({ +export const index = defineAkteFile().from({ path: "/", async data() { await new Promise((resolve) => setTimeout(resolve, 2000)); diff --git a/playground/src/pages/posts/slug.ts b/playground/src/pages/posts/slug.ts index d35b16d..56236ae 100644 --- a/playground/src/pages/posts/slug.ts +++ b/playground/src/pages/posts/slug.ts @@ -2,7 +2,7 @@ import { type PrismicDocument, createClient } from "@prismicio/client"; import fetch from "node-fetch"; import { defineAkteFiles } from "akte"; -import { basic } from "../../layouts/basic"; +import { basic } from "../../layouts/basic.js"; const client = createClient("lihbr", { routes: [ diff --git a/playground/vite.config.ts b/playground/vite.config.ts index 0f0290a..d1cc1c9 100644 --- a/playground/vite.config.ts +++ b/playground/vite.config.ts @@ -1,7 +1,7 @@ import { defineConfig } from "vite"; import akte from "akte/vite"; -import { app } from "./akte.app"; +import { app } from "./akte.app.js"; export default defineConfig({ root: "src", diff --git a/src/AkteApp.ts b/src/AkteApp.ts index 3a26291..ee7e78f 100644 --- a/src/AkteApp.ts +++ b/src/AkteApp.ts @@ -3,21 +3,21 @@ import { mkdir, writeFile } from "node:fs/promises"; import { type MatchedRoute, type RadixRouter, createRouter } from "radix3"; -import type { AkteFiles } from "./AkteFiles"; -import type { Awaitable, GlobalDataFn } from "./types"; -import { NotFoundError } from "./errors"; -import { runCLI } from "./runCLI"; -import { akteWelcome } from "./akteWelcome"; +import type { AkteFiles } from "./AkteFiles.js"; +import type { Awaitable, GlobalDataFn } from "./types.js"; +import { NotFoundError } from "./errors.js"; +import { runCLI } from "./runCLI.js"; +import { akteWelcome } from "./akteWelcome.js"; -import { __PRODUCTION__ } from "./lib/__PRODUCTION__"; -import { createDebugger } from "./lib/createDebugger"; -import { pathToRouterPath } from "./lib/pathToRouterPath"; -import { isCLI } from "./lib/isCLI"; +import { __PRODUCTION__ } from "./lib/__PRODUCTION__.js"; +import { createDebugger } from "./lib/createDebugger.js"; +import { pathToRouterPath } from "./lib/pathToRouterPath.js"; +import { isCLI } from "./lib/isCLI.js"; /* eslint-disable @typescript-eslint/no-unused-vars, unused-imports/no-unused-imports */ -import type { defineAkteFile } from "./defineAkteFile"; -import type { defineAkteFiles } from "./defineAkteFiles"; +import type { defineAkteFile } from "./defineAkteFile.js"; +import type { defineAkteFiles } from "./defineAkteFiles.js"; /* eslint-enable @typescript-eslint/no-unused-vars, unused-imports/no-unused-imports */ diff --git a/src/AkteFiles.ts b/src/AkteFiles.ts index 19933c3..f3fa947 100644 --- a/src/AkteFiles.ts +++ b/src/AkteFiles.ts @@ -1,13 +1,13 @@ -import { NotFoundError } from "./errors"; -import { type Awaitable } from "./types"; +import { NotFoundError } from "./errors.js"; +import { type Awaitable } from "./types.js"; -import { createDebugger } from "./lib/createDebugger"; -import { pathToFilePath } from "./lib/pathToFilePath"; -import { toReadonlyMap } from "./lib/toReadonlyMap"; +import { createDebugger } from "./lib/createDebugger.js"; +import { pathToFilePath } from "./lib/pathToFilePath.js"; +import { toReadonlyMap } from "./lib/toReadonlyMap.js"; /* eslint-disable @typescript-eslint/no-unused-vars, unused-imports/no-unused-imports */ -import type { AkteApp } from "./AkteApp"; +import type { AkteApp } from "./AkteApp.js"; /* eslint-enable @typescript-eslint/no-unused-vars, unused-imports/no-unused-imports */ diff --git a/src/akteWelcome.ts b/src/akteWelcome.ts index e0a8dc4..71c19e6 100644 --- a/src/akteWelcome.ts +++ b/src/akteWelcome.ts @@ -2,9 +2,9 @@ import * as fs from "node:fs/promises"; import * as path from "node:path"; import { createRequire } from "node:module"; -import { __PRODUCTION__ } from "./lib/__PRODUCTION__"; -import { defineAkteFiles } from "./defineAkteFiles"; -import { NotFoundError } from "./errors"; +import { __PRODUCTION__ } from "./lib/__PRODUCTION__.js"; +import { defineAkteFiles } from "./defineAkteFiles.js"; +import { NotFoundError } from "./errors.js"; /** * Akte welcome page shown in development when the Akte app does not have any diff --git a/src/defineAkteApp.ts b/src/defineAkteApp.ts index c3ee187..f5963cf 100644 --- a/src/defineAkteApp.ts +++ b/src/defineAkteApp.ts @@ -1,4 +1,4 @@ -import { AkteApp, type Config } from "./AkteApp"; +import { AkteApp, type Config } from "./AkteApp.js"; /** * Creates an Akte app from given configuration. diff --git a/src/defineAkteFile.ts b/src/defineAkteFile.ts index 4fc58ed..e473a10 100644 --- a/src/defineAkteFile.ts +++ b/src/defineAkteFile.ts @@ -3,8 +3,8 @@ import { type FilesBulkDataFn, type FilesDataFn, type FilesDefinition, -} from "./AkteFiles"; -import type { Empty } from "./types"; +} from "./AkteFiles.js"; +import type { Empty } from "./types.js"; type FileDefinition = Omit< FilesDefinition, diff --git a/src/defineAkteFiles.ts b/src/defineAkteFiles.ts index 779148d..3dc6bbf 100644 --- a/src/defineAkteFiles.ts +++ b/src/defineAkteFiles.ts @@ -3,9 +3,9 @@ import { type FilesBulkDataFn, type FilesDataFn, type FilesDefinition, -} from "./AkteFiles"; +} from "./AkteFiles.js"; -import type { Empty } from "./types"; +import type { Empty } from "./types.js"; /** * Creates an Akte files instance. diff --git a/src/errors.ts b/src/errors.ts index ffccc00..ee08821 100644 --- a/src/errors.ts +++ b/src/errors.ts @@ -6,21 +6,25 @@ export class NotFoundError extends Error { path: string; + // This property already exists on Error, but TypeScript is unaware + declare cause?: unknown; + constructor( path: string, options?: { cause?: unknown; }, ) { - if (!options?.cause) { - super(`Could lookup file for path \`${path}\``, options); - } else { - super( - `Could lookup file for path \`${path}\`\n\n${options.cause.toString()}`, - options, - ); + const cause = options?.cause; + let message = `Could lookup file for path \`${path}\``; + + if (cause) { + message += `\n\n${cause.toString()}`; } + // @ts-expect-error - TypeScript doesn't know Node 16 has the two argument Error constructor + super(message, options); + this.path = path; } } diff --git a/src/index.ts b/src/index.ts index 437135f..14260c6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,8 +1,8 @@ -export type { Config, AkteApp } from "./AkteApp"; -export type { AkteFiles } from "./AkteFiles"; +export type { Config, AkteApp } from "./AkteApp.js"; +export type { AkteFiles } from "./AkteFiles.js"; -export { defineAkteApp } from "./defineAkteApp"; -export { defineAkteFile } from "./defineAkteFile"; -export { defineAkteFiles } from "./defineAkteFiles"; +export { defineAkteApp } from "./defineAkteApp.js"; +export { defineAkteFile } from "./defineAkteFile.js"; +export { defineAkteFiles } from "./defineAkteFiles.js"; -export { NotFoundError } from "./errors"; +export { NotFoundError } from "./errors.js"; diff --git a/src/lib/createDebugger.ts b/src/lib/createDebugger.ts index 9fde3b0..0ba6e5b 100644 --- a/src/lib/createDebugger.ts +++ b/src/lib/createDebugger.ts @@ -1,6 +1,6 @@ import debug from "debug"; -import { hasHelp, hasSilent, hasVersion } from "./hasFlag"; -import { isCLI } from "./isCLI"; +import { hasHelp, hasSilent, hasVersion } from "./hasFlag.js"; +import { isCLI } from "./isCLI.js"; type DebuggerFn = (msg: unknown, ...args: unknown[]) => void; type Debugger = DebuggerFn & { diff --git a/src/lib/hasFlag.ts b/src/lib/hasFlag.ts index 8210661..9cc206f 100644 --- a/src/lib/hasFlag.ts +++ b/src/lib/hasFlag.ts @@ -1,4 +1,4 @@ -import { commandsAndFlags } from "./commandsAndFlags"; +import { commandsAndFlags } from "./commandsAndFlags.js"; const hasFlag = (...flags: string[]): boolean => { for (const flag of flags) { diff --git a/src/lib/pathToRouterPath.ts b/src/lib/pathToRouterPath.ts index 6cfe2be..4c64278 100644 --- a/src/lib/pathToRouterPath.ts +++ b/src/lib/pathToRouterPath.ts @@ -1,4 +1,4 @@ -import { pathToFilePath } from "./pathToFilePath"; +import { pathToFilePath } from "./pathToFilePath.js"; export const pathToRouterPath = (path: string): string => { const filePath = pathToFilePath(path); diff --git a/src/runCLI.ts b/src/runCLI.ts index 3c7c298..82a8038 100644 --- a/src/runCLI.ts +++ b/src/runCLI.ts @@ -1,9 +1,9 @@ -import { type AkteApp } from "./AkteApp"; +import { type AkteApp } from "./AkteApp.js"; -import { commandsAndFlags } from "./lib/commandsAndFlags"; -import { createDebugger } from "./lib/createDebugger"; -import { hasHelp, hasVersion } from "./lib/hasFlag"; -import { pkg } from "./lib/pkg"; +import { commandsAndFlags } from "./lib/commandsAndFlags.js"; +import { createDebugger } from "./lib/createDebugger.js"; +import { hasHelp, hasVersion } from "./lib/hasFlag.js"; +import { pkg } from "./lib/pkg.js"; const debugCLI = createDebugger("akte:cli"); diff --git a/src/vite/AkteViteCache.ts b/src/vite/AkteViteCache.ts index 30d5eb6..74f2912 100644 --- a/src/vite/AkteViteCache.ts +++ b/src/vite/AkteViteCache.ts @@ -1,9 +1,9 @@ import { dirname, resolve } from "node:path"; import { mkdir, readFile, rm, writeFile } from "node:fs/promises"; -import type { AkteFiles } from "../AkteFiles"; -import { type Awaitable } from "../types"; -import { pathToFilePath } from "../lib/pathToFilePath"; +import type { AkteFiles } from "../AkteFiles.js"; +import { type Awaitable } from "../types.js"; +import { pathToFilePath } from "../lib/pathToFilePath.js"; const GLOBAL_DATA = "app.globalData"; const DATA = "file.data"; diff --git a/src/vite/aktePlugin.ts b/src/vite/aktePlugin.ts index f5e5476..8e49ef9 100644 --- a/src/vite/aktePlugin.ts +++ b/src/vite/aktePlugin.ts @@ -1,9 +1,9 @@ import { type PluginOption } from "vite"; -import { createDebugger } from "../lib/createDebugger"; -import { serverPlugin } from "./plugins/serverPlugin"; -import { buildPlugin } from "./plugins/buildPlugin"; -import type { Options, ResolvedOptions } from "./types"; +import { createDebugger } from "../lib/createDebugger.js"; +import { serverPlugin } from "./plugins/serverPlugin.js"; +import { buildPlugin } from "./plugins/buildPlugin.js"; +import type { Options, ResolvedOptions } from "./types.js"; const MINIFY_HTML_DEFAULT_OPTIONS = { collapseBooleanAttributes: true, diff --git a/src/vite/createAkteViteCache.ts b/src/vite/createAkteViteCache.ts index 674912c..3133c7a 100644 --- a/src/vite/createAkteViteCache.ts +++ b/src/vite/createAkteViteCache.ts @@ -1,4 +1,4 @@ -import { AkteViteCache } from "./AkteViteCache"; +import { AkteViteCache } from "./AkteViteCache.js"; export const createAkteViteCache = (root: string): AkteViteCache => { return new AkteViteCache(root); diff --git a/src/vite/index.ts b/src/vite/index.ts index 7716537..66cd111 100644 --- a/src/vite/index.ts +++ b/src/vite/index.ts @@ -1,4 +1,4 @@ -import { aktePlugin } from "./aktePlugin"; +import { aktePlugin } from "./aktePlugin.js"; export default aktePlugin; -export type { Options } from "./types"; +export type { Options } from "./types.js"; diff --git a/src/vite/plugins/buildPlugin.ts b/src/vite/plugins/buildPlugin.ts index da1aa02..9471d96 100644 --- a/src/vite/plugins/buildPlugin.ts +++ b/src/vite/plugins/buildPlugin.ts @@ -5,10 +5,10 @@ import { existsSync } from "node:fs"; import type { Plugin } from "vite"; -import type { ResolvedOptions } from "../types"; -import { createAkteViteCache } from "../createAkteViteCache"; -import { pkg } from "../../lib/pkg"; -import { createDebugger } from "../../lib/createDebugger"; +import type { ResolvedOptions } from "../types.js"; +import { createAkteViteCache } from "../createAkteViteCache.js"; +import { pkg } from "../../lib/pkg.js"; +import { createDebugger } from "../../lib/createDebugger.js"; let isServerRestart = false; diff --git a/src/vite/plugins/serverPlugin.ts b/src/vite/plugins/serverPlugin.ts index 2ca479f..41faf0b 100644 --- a/src/vite/plugins/serverPlugin.ts +++ b/src/vite/plugins/serverPlugin.ts @@ -4,11 +4,11 @@ import { mkdir, writeFile } from "node:fs/promises"; import type { Plugin } from "vite"; import httpProxy from "http-proxy"; -import type { ResolvedOptions } from "../types"; -import { createAkteViteCache } from "../createAkteViteCache"; -import { NotFoundError } from "../../errors"; -import { pathToFilePath } from "../../lib/pathToFilePath"; -import { createDebugger } from "../../lib/createDebugger"; +import type { ResolvedOptions } from "../types.js"; +import { createAkteViteCache } from "../createAkteViteCache.js"; +import { NotFoundError } from "../../errors.js"; +import { pathToFilePath } from "../../lib/pathToFilePath.js"; +import { createDebugger } from "../../lib/createDebugger.js"; const debug = createDebugger("akte:vite:server", true); diff --git a/src/vite/types.ts b/src/vite/types.ts index 9c25759..6104b31 100644 --- a/src/vite/types.ts +++ b/src/vite/types.ts @@ -1,6 +1,6 @@ import type { Options as MinifyHTMLOptions } from "html-minifier-terser"; -import { type AkteApp } from "../AkteApp"; +import { type AkteApp } from "../AkteApp.js"; /** Akte Vite plugin options. */ export type Options = { diff --git a/test/AkteApp-buildAll.test.ts b/test/AkteApp-buildAll.test.ts index 6eb7ac9..8a3ae58 100644 --- a/test/AkteApp-buildAll.test.ts +++ b/test/AkteApp-buildAll.test.ts @@ -2,13 +2,13 @@ import { posix } from "node:path"; import { expect, it } from "vitest"; import { vol } from "memfs"; -import { defineAkteApp } from "../src"; +import { defineAkteApp } from "../src/index.js"; -import { index } from "./__fixtures__"; -import { about } from "./__fixtures__/about"; -import { pages } from "./__fixtures__/pages"; -import { posts } from "./__fixtures__/posts"; -import { jsons } from "./__fixtures__/jsons"; +import { index } from "./__fixtures__/index.js"; +import { about } from "./__fixtures__/about.js"; +import { pages } from "./__fixtures__/pages.js"; +import { posts } from "./__fixtures__/posts.js"; +import { jsons } from "./__fixtures__/jsons.js"; it("builds all files at default output directory", async () => { const app = defineAkteApp({ diff --git a/test/AkteApp-getGlobalData.test.ts b/test/AkteApp-getGlobalData.test.ts index 3239763..a50908c 100644 --- a/test/AkteApp-getGlobalData.test.ts +++ b/test/AkteApp-getGlobalData.test.ts @@ -1,12 +1,12 @@ import { expect, it, vi } from "vitest"; -import { defineAkteApp } from "../src"; +import { defineAkteApp } from "../src/index.js"; -import { index } from "./__fixtures__"; -import { about } from "./__fixtures__/about"; -import { pages } from "./__fixtures__/pages"; -import { posts } from "./__fixtures__/posts"; -import { jsons } from "./__fixtures__/jsons"; +import { index } from "./__fixtures__/index.js"; +import { about } from "./__fixtures__/about.js"; +import { pages } from "./__fixtures__/pages.js"; +import { posts } from "./__fixtures__/posts.js"; +import { jsons } from "./__fixtures__/jsons.js"; it("caches global data", async () => { const globalDataFn = vi.fn().mockImplementation(() => true); diff --git a/test/AkteApp-getRouter.test.ts b/test/AkteApp-getRouter.test.ts index f03c846..8aaeaf2 100644 --- a/test/AkteApp-getRouter.test.ts +++ b/test/AkteApp-getRouter.test.ts @@ -2,13 +2,13 @@ import { expect, it, vi } from "vitest"; import { createRouter } from "radix3"; -import { defineAkteApp } from "../src"; +import { defineAkteApp } from "../src/index.js"; -import { index } from "./__fixtures__"; -import { about } from "./__fixtures__/about"; -import { pages } from "./__fixtures__/pages"; -import { posts } from "./__fixtures__/posts"; -import { jsons } from "./__fixtures__/jsons"; +import { index } from "./__fixtures__/index.js"; +import { about } from "./__fixtures__/about.js"; +import { pages } from "./__fixtures__/pages.js"; +import { posts } from "./__fixtures__/posts.js"; +import { jsons } from "./__fixtures__/jsons.js"; vi.mock("radix3", () => { return { diff --git a/test/AkteApp-lookup.test.ts b/test/AkteApp-lookup.test.ts index d290609..60919c9 100644 --- a/test/AkteApp-lookup.test.ts +++ b/test/AkteApp-lookup.test.ts @@ -1,12 +1,12 @@ import { expect, it } from "vitest"; -import { NotFoundError, defineAkteApp } from "../src"; +import { NotFoundError, defineAkteApp } from "../src/index.js"; -import { index } from "./__fixtures__"; -import { about } from "./__fixtures__/about"; -import { pages } from "./__fixtures__/pages"; -import { posts } from "./__fixtures__/posts"; -import { jsons } from "./__fixtures__/jsons"; +import { index } from "./__fixtures__/index.js"; +import { about } from "./__fixtures__/about.js"; +import { pages } from "./__fixtures__/pages.js"; +import { posts } from "./__fixtures__/posts.js"; +import { jsons } from "./__fixtures__/jsons.js"; const app = defineAkteApp({ files: [index, about, pages, posts, jsons] }); diff --git a/test/AkteApp-render.test.ts b/test/AkteApp-render.test.ts index 85d595f..8cac957 100644 --- a/test/AkteApp-render.test.ts +++ b/test/AkteApp-render.test.ts @@ -1,13 +1,13 @@ import { expect, it } from "vitest"; -import { NotFoundError, defineAkteApp } from "../src"; +import { NotFoundError, defineAkteApp } from "../src/index.js"; -import { index } from "./__fixtures__"; -import { about } from "./__fixtures__/about"; -import { pages } from "./__fixtures__/pages"; -import { posts } from "./__fixtures__/posts"; -import { jsons } from "./__fixtures__/jsons"; -import { renderError } from "./__fixtures__/renderError"; +import { index } from "./__fixtures__/index.js"; +import { about } from "./__fixtures__/about.js"; +import { pages } from "./__fixtures__/pages.js"; +import { posts } from "./__fixtures__/posts.js"; +import { jsons } from "./__fixtures__/jsons.js"; +import { renderError } from "./__fixtures__/renderError.js"; const app = defineAkteApp({ files: [index, about, pages, posts, jsons, renderError], diff --git a/test/AkteApp-renderAll.test.ts b/test/AkteApp-renderAll.test.ts index a992262..208f1bb 100644 --- a/test/AkteApp-renderAll.test.ts +++ b/test/AkteApp-renderAll.test.ts @@ -1,14 +1,14 @@ import { expect, it, vi } from "vitest"; -import { defineAkteApp } from "../src"; +import { defineAkteApp } from "../src/index.js"; -import { index } from "./__fixtures__"; -import { about } from "./__fixtures__/about"; -import { pages } from "./__fixtures__/pages"; -import { posts } from "./__fixtures__/posts"; -import { jsons } from "./__fixtures__/jsons"; -import { renderError } from "./__fixtures__/renderError"; -import { noGlobalData } from "./__fixtures__/noGlobalData"; +import { index } from "./__fixtures__/index.js"; +import { about } from "./__fixtures__/about.js"; +import { pages } from "./__fixtures__/pages.js"; +import { posts } from "./__fixtures__/posts.js"; +import { jsons } from "./__fixtures__/jsons.js"; +import { renderError } from "./__fixtures__/renderError.js"; +import { noGlobalData } from "./__fixtures__/noGlobalData.js"; it("renders all files", async () => { const app = defineAkteApp({ diff --git a/test/AkteApp-writeAll.test.ts b/test/AkteApp-writeAll.test.ts index ff43a93..7fe53a2 100644 --- a/test/AkteApp-writeAll.test.ts +++ b/test/AkteApp-writeAll.test.ts @@ -2,13 +2,13 @@ import { posix } from "node:path"; import { expect, it, vi } from "vitest"; import { vol } from "memfs"; -import { defineAkteApp } from "../src"; +import { defineAkteApp } from "../src/index.js"; -import { index } from "./__fixtures__"; -import { about } from "./__fixtures__/about"; -import { pages } from "./__fixtures__/pages"; -import { posts } from "./__fixtures__/posts"; -import { jsons } from "./__fixtures__/jsons"; +import { index } from "./__fixtures__/index.js"; +import { about } from "./__fixtures__/about.js"; +import { pages } from "./__fixtures__/pages.js"; +import { posts } from "./__fixtures__/posts.js"; +import { jsons } from "./__fixtures__/jsons.js"; it("writes all files at default output directory", async () => { const app = defineAkteApp({ diff --git a/test/AkteFile-getBulkData.test.ts b/test/AkteFile-getBulkData.test.ts index c48ee36..3c1c387 100644 --- a/test/AkteFile-getBulkData.test.ts +++ b/test/AkteFile-getBulkData.test.ts @@ -1,6 +1,6 @@ import { expect, it, vi } from "vitest"; -import { defineAkteFile, defineAkteFiles } from "../src"; +import { defineAkteFile, defineAkteFiles } from "../src/index.js"; it("caches bulk data", () => { const bulkDataFn = vi.fn().mockImplementation(() => ({ diff --git a/test/AkteFile-getData.test.ts b/test/AkteFile-getData.test.ts index 8f2c994..2ad0cc5 100644 --- a/test/AkteFile-getData.test.ts +++ b/test/AkteFile-getData.test.ts @@ -1,6 +1,6 @@ import { expect, it, vi } from "vitest"; -import { defineAkteFiles } from "../src"; +import { defineAkteFiles } from "../src/index.js"; it("caches data", () => { const dataFn = vi.fn().mockImplementation(() => true); diff --git a/test/__fixtures__/about.ts b/test/__fixtures__/about.ts index 572934c..5509282 100644 --- a/test/__fixtures__/about.ts +++ b/test/__fixtures__/about.ts @@ -1,4 +1,4 @@ -import { defineAkteFile } from "../../src"; +import { defineAkteFile } from "../../src/index.js"; export const about = defineAkteFile().from({ path: "/about", diff --git a/test/__fixtures__/index.ts b/test/__fixtures__/index.ts index 9d9fea0..3974f9d 100644 --- a/test/__fixtures__/index.ts +++ b/test/__fixtures__/index.ts @@ -1,4 +1,4 @@ -import { defineAkteFile } from "../../src"; +import { defineAkteFile } from "../../src/index.js"; export const index = defineAkteFile().from({ path: "/", diff --git a/test/__fixtures__/jsons.ts b/test/__fixtures__/jsons.ts index 6e12f54..113ee78 100644 --- a/test/__fixtures__/jsons.ts +++ b/test/__fixtures__/jsons.ts @@ -1,4 +1,4 @@ -import { defineAkteFiles } from "../../src"; +import { defineAkteFiles } from "../../src/index.js"; export const jsons = defineAkteFiles().from({ path: "/:slug.json", diff --git a/test/__fixtures__/noGlobalData.ts b/test/__fixtures__/noGlobalData.ts index 31464c5..beb4ebc 100644 --- a/test/__fixtures__/noGlobalData.ts +++ b/test/__fixtures__/noGlobalData.ts @@ -1,4 +1,4 @@ -import { defineAkteFiles } from "../../src"; +import { defineAkteFiles } from "../../src/index.js"; export const noGlobalData = defineAkteFiles().from({ path: "/no-global-data/:slug", diff --git a/test/__fixtures__/pages.ts b/test/__fixtures__/pages.ts index 3bdc4bc..aa61f9d 100644 --- a/test/__fixtures__/pages.ts +++ b/test/__fixtures__/pages.ts @@ -1,4 +1,4 @@ -import { defineAkteFiles } from "../../src"; +import { defineAkteFiles } from "../../src/index.js"; export const pages = defineAkteFiles().from({ path: "/pages/**", diff --git a/test/__fixtures__/posts.ts b/test/__fixtures__/posts.ts index 2bb770f..82c353b 100644 --- a/test/__fixtures__/posts.ts +++ b/test/__fixtures__/posts.ts @@ -1,4 +1,4 @@ -import { defineAkteFiles } from "../../src"; +import { defineAkteFiles } from "../../src/index.js"; export const posts = defineAkteFiles().from({ path: "/posts/:slug", diff --git a/test/__fixtures__/renderError.ts b/test/__fixtures__/renderError.ts index e2564cb..82dad4f 100644 --- a/test/__fixtures__/renderError.ts +++ b/test/__fixtures__/renderError.ts @@ -1,4 +1,4 @@ -import { defineAkteFiles } from "../../src"; +import { defineAkteFiles } from "../../src/index.js"; export const renderError = defineAkteFiles().from({ path: "/render-error/:slug", diff --git a/test/defineAkteApp.test-d.ts b/test/defineAkteApp.test-d.ts index 98b1b5d..ce7e94b 100644 --- a/test/defineAkteApp.test-d.ts +++ b/test/defineAkteApp.test-d.ts @@ -1,5 +1,5 @@ import { it } from "vitest"; -import { defineAkteApp, defineAkteFiles } from "../src"; +import { defineAkteApp, defineAkteFiles } from "../src/index.js"; const noGlobalData = defineAkteFiles().from({ path: "/:slug", diff --git a/test/defineAkteFile.test-d.ts b/test/defineAkteFile.test-d.ts index 2ee9974..8973011 100644 --- a/test/defineAkteFile.test-d.ts +++ b/test/defineAkteFile.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf, it } from "vitest"; -import { defineAkteFile } from "../src"; +import { defineAkteFile } from "../src/index.js"; it("infers data from data", () => { defineAkteFile().from({ diff --git a/test/defineAkteFiles.test-d.ts b/test/defineAkteFiles.test-d.ts index e91a9ca..2fbff28 100644 --- a/test/defineAkteFiles.test-d.ts +++ b/test/defineAkteFiles.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf, it } from "vitest"; -import { defineAkteFiles } from "../src"; +import { defineAkteFiles } from "../src/index.js"; it("infers data from data", () => { defineAkteFiles().from({ diff --git a/test/index.test.ts b/test/index.test.ts index fc5a1ea..2a1cea9 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -1,6 +1,6 @@ import { expect, it } from "vitest"; -import * as lib from "../src"; +import * as lib from "../src/index.js"; // TODO: Dummy test, meant to be removed when real tests come in it("exports something", () => { diff --git a/test/runCLI.test.ts b/test/runCLI.test.ts index 3ad33b4..ff0ff43 100644 --- a/test/runCLI.test.ts +++ b/test/runCLI.test.ts @@ -1,14 +1,14 @@ import { expect, it, vi } from "vitest"; import { vol } from "memfs"; -import { defineAkteApp } from "../src"; -import { runCLI } from "../src/runCLI"; +import { defineAkteApp } from "../src/index.js"; +import { runCLI } from "../src/runCLI.js"; -import { index } from "./__fixtures__"; -import { about } from "./__fixtures__/about"; -import { pages } from "./__fixtures__/pages"; -import { posts } from "./__fixtures__/posts"; -import { jsons } from "./__fixtures__/jsons"; +import { index } from "./__fixtures__/index.js"; +import { about } from "./__fixtures__/about.js"; +import { pages } from "./__fixtures__/pages.js"; +import { posts } from "./__fixtures__/posts.js"; +import { jsons } from "./__fixtures__/jsons.js"; it("builds product upon build command", async () => { const app = defineAkteApp({ diff --git a/tsconfig.json b/tsconfig.json index 393e207..31c914e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,17 +3,17 @@ "strict": true, "skipLibCheck": true, - "target": "esnext", - "module": "esnext", + "target": "ES2021", + "module": "Node16", "declaration": false, - "moduleResolution": "node", + "moduleResolution": "Node16", "resolveJsonModule": true, "allowSyntheticDefaultImports": true, "esModuleInterop": true, "forceConsistentCasingInFileNames": true, "jsx": "preserve", - "lib": ["esnext", "dom"], + "lib": ["ES2021", "DOM"], "types": ["node"] }, "exclude": ["node_modules", "dist", "examples"] diff --git a/vite.config.ts b/vite.config.ts index 9c051a6..1497fb1 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -5,7 +5,7 @@ import { defineConfig } from "vite"; import sdk from "vite-plugin-sdk"; import { minify } from "html-minifier-terser"; -import { app } from "./docs/akte.app"; +import { app } from "./docs/akte.app.js"; const MINIFY_HTML_OPTIONS = { collapseBooleanAttributes: true,