|
1 | 1 | /* eslint-disable @typescript-eslint/no-deprecated -- Verify that deprecated compatibility exports remain usable. */ |
2 | 2 | import assert from "node:assert"; |
| 3 | +import { readFileSync, readdirSync } from "node:fs"; |
| 4 | +import { join } from "node:path"; |
3 | 5 | import { fileURLToPath } from "node:url"; |
4 | 6 | import * as legacy from "@cloudflare/workers-utils"; |
5 | 7 | import * as config from "@cloudflare/workers-utils/config"; |
6 | 8 | import ts from "typescript"; |
7 | 9 | import { expectTypeOf, test } from "vitest"; |
8 | 10 |
|
| 11 | +test("published configuration bundles private asset helpers", ({ expect }) => { |
| 12 | + const distPath = fileURLToPath(new URL("../dist/", import.meta.url)); |
| 13 | + const files = readdirSync(distPath, { |
| 14 | + recursive: true, |
| 15 | + encoding: "utf8", |
| 16 | + }).filter((file) => file.endsWith(".mjs")); |
| 17 | + expect(files.length).toBeGreaterThan(0); |
| 18 | + for (const file of files) { |
| 19 | + const source = readFileSync(join(distPath, file), "utf8"); |
| 20 | + const imports = ts |
| 21 | + .preProcessFile(source, true, true) |
| 22 | + .importedFiles.map(({ fileName }) => fileName); |
| 23 | + expect(imports, file).not.toEqual( |
| 24 | + expect.arrayContaining([ |
| 25 | + expect.stringMatching(/^@cloudflare\/workers-shared(?:\/|$)/), |
| 26 | + ]) |
| 27 | + ); |
| 28 | + } |
| 29 | +}); |
| 30 | + |
9 | 31 | test("published config entry points share runtime values", ({ expect }) => { |
10 | 32 | for (const [name, value] of Object.entries(config)) { |
11 | 33 | if ( |
|
0 commit comments