Skip to content

Commit

Permalink
Switch from CommonJS to ESM for support for TypeDoc 0.27.x
Browse files Browse the repository at this point in the history
  • Loading branch information
awa-xima committed Nov 27, 2024
1 parent 1df852a commit 845ec82
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 204 deletions.
216 changes: 28 additions & 188 deletions data/web-api.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "typedoc-plugin-mdn-links",
"version": "4.0.1",
"main": "dist/index.js",
"type": "module",
"license": "MIT",
"devDependencies": {
"@webgpu/types": "^0.1.43",
Expand Down
11 changes: 7 additions & 4 deletions scripts/generateWebApiIndex.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
const bcd = require("@mdn/browser-compat-data");
const { writeFileSync } = require("fs");
const { join } = require("path");
import bcd from "@mdn/browser-compat-data" assert { type: "json" };
import { writeFileSync } from "node:fs";
import { join, resolve } from "node:path";
import { fileURLToPath } from "node:url";

const dirname = resolve(fileURLToPath(import.meta.url), "..");

/** @typedef {import("../src/webApi").WebApiData} WebApiData */

Expand Down Expand Up @@ -61,6 +64,6 @@ for (const key in bcd.javascript.builtins) {

console.log("There are", Object.keys(results).length, "root entries.");
writeFileSync(
join(__dirname, "../data/web-api.json"),
join(dirname, "../data/web-api.json"),
JSON.stringify(results, null, "\t"),
);
12 changes: 6 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import {
Application,
CommentDisplayPart,
ComponentPath,
type CommentDisplayPart,
type ComponentPath,
Converter,
DeclarationReference,
type DeclarationReference,
ParameterType,
Reflection,
ReflectionSymbolId,
splitUnquotedString,
SymbolReference,
type SymbolReference,
} from "typedoc";
import { resolveTsType } from "./typescript";
import { resolveWebApiPath } from "./webApi";
import { resolveTsType } from "./typescript.js";
import { resolveWebApiPath } from "./webApi.js";

declare module "typedoc" {
export interface TypeDocOptionMap {
Expand Down
2 changes: 1 addition & 1 deletion src/test/plugin.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
Application,
DeclarationReflection,
InlineTagDisplayPart,
type InlineTagDisplayPart,
ProjectReflection,
QueryType,
ReferenceType,
Expand Down
2 changes: 1 addition & 1 deletion src/typescript.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ComponentPath } from "typedoc";
import type { ComponentPath } from "typedoc";

const utilityTypes = new Map([
["Awaited", "awaitedtype"],
Expand Down
4 changes: 2 additions & 2 deletions src/webApi.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { ComponentPath } from "typedoc";
import type { ComponentPath } from "typedoc";

export interface WebApiData {
url: string;
inst?: Record<string, WebApiData | string>;
stat?: Record<string, WebApiData | string>;
}

import _webApi from "#data";
import _webApi from "#data" assert { type: "json" };
const webApi = _webApi as Record<string, WebApiData | string>;

function resolvePath(
Expand Down
5 changes: 3 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"target": "es2020",
"module": "Node16",
"module": "NodeNext",
"lib": ["ESNext", "DOM"],
"rootDir": "src",
"strict": true,
Expand All @@ -10,7 +10,8 @@
"resolveJsonModule": true,
"outDir": "dist",
"types": [],
"skipLibCheck": true
"skipLibCheck": true,
"verbatimModuleSyntax": true
},
"include": ["."]
}

0 comments on commit 845ec82

Please sign in to comment.