Unverified Commit d7cb9ef3 authored by Hong Minhee's avatar Hong Minhee
Browse files

Bundle modules into neutral modules

parent 798989c6
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -275,6 +275,7 @@ export async function loadSchemaFiles(
  const errors: SchemaError[] = [];
  for await (const relPath of readDirRecursive(dir)) {
    if (!relPath.match(/\.ya?ml$/i)) continue;
    if (relPath.match(/(^|[/\\])schema.yaml$/i)) continue;
    const path = join(dir, relPath);
    let schema: TypeSchema;
    try {
+76 −61
Original line number Diff line number Diff line
@@ -2,7 +2,8 @@ import { cp, glob } from "node:fs/promises";
import { join, sep } from "node:path";
import { defineConfig } from "tsdown";

export default defineConfig({
export default [
  defineConfig({
    entry: [
      "./mod.ts",
      "./compat/mod.ts",
@@ -10,12 +11,25 @@ export default defineConfig({
      "./nodeinfo/mod.ts",
      "./runtime/mod.ts",
      "./sig/mod.ts",
    "./testing/mod.ts",
      "./vocab/mod.ts",
      "./webfinger/mod.ts",
      "./x/cfworkers.ts",
      "./x/hono.ts",
      "./x/sveltekit.ts",
    ],
    dts: true,
    platform: "neutral",
    external: [/^node:/],
    outputOptions: {
      intro: `
      import { Temporal } from "@js-temporal/polyfill";
      import { URLPattern } from "urlpattern-polyfill";
    `,
    },
  }),
  defineConfig({
    entry: [
      "./testing/mod.ts",
      ...(await Array.fromAsync(glob(`**/*.test.ts`)))
        .filter((f) =>
          !f.startsWith(`codegen${sep}`) && f !== `x${sep}denokv.test.ts`
@@ -23,7 +37,6 @@ export default defineConfig({
        .map((f) => f.replace(sep, "/")),
    ],
    dts: true,
  unbundle: true,
    external: [/^node:/],
    inputOptions: {
      onwarn(warning, defaultHandler) {
@@ -47,18 +60,19 @@ export default defineConfig({
      intro: `
      import { Temporal } from "@js-temporal/polyfill";
      import { URLPattern } from "urlpattern-polyfill";
      globalThis.addEventListener = () => {};
    `,
    },
    hooks: {
      "build:done": async (ctx) => {
        await cp(
          join("testing", "fixtures"),
        join(ctx.options.outDir, "testing", "fixtures"),
          join(ctx.options.outDir, "fixtures"),
          { recursive: true },
        );
        await cp(
          join("codegen", "schema.yaml"),
        join(ctx.options.outDir, "codegen", "schema.yaml"),
          join(ctx.options.outDir, "vocab", "schema.yaml"),
          { force: true },
        );
        for await (const file of glob(`vocab/**/*.yaml`)) {
@@ -70,6 +84,7 @@ export default defineConfig({
        }
      },
    },
});
  }),
];

// cSpell: ignore unbundle