mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-10-30 09:16:55 +00:00
perf(core): light entries for safe paths, asset paths and the runtime script (#4642)
This commit is contained in:
@@ -38,6 +38,24 @@
|
||||
"types": "./dist/utils/htmlAttrSafety.d.ts",
|
||||
"environments": ["browser", "bun", "node"]
|
||||
},
|
||||
"./safe-path": {
|
||||
"source": "./src/safePath.ts",
|
||||
"runtime": "./dist/safePath.js",
|
||||
"types": "./dist/safePath.d.ts",
|
||||
"environments": ["bun", "node"]
|
||||
},
|
||||
"./asset-paths": {
|
||||
"source": "./src/compiler/rewriteSubCompPaths.ts",
|
||||
"runtime": "./dist/compiler/rewriteSubCompPaths.js",
|
||||
"types": "./dist/compiler/rewriteSubCompPaths.d.ts",
|
||||
"environments": ["bun", "node"]
|
||||
},
|
||||
"./runtime-script": {
|
||||
"source": "./src/generated/runtime-inline.ts",
|
||||
"runtime": "./dist/generated/runtime-inline.js",
|
||||
"types": "./dist/generated/runtime-inline.d.ts",
|
||||
"environments": ["browser", "bun", "node"]
|
||||
},
|
||||
"./rich-text-sanitize": {
|
||||
"source": "./src/utils/richTextSanitize.ts",
|
||||
"runtime": "./dist/utils/richTextSanitize.js",
|
||||
|
||||
@@ -52,6 +52,24 @@
|
||||
"import": "./src/utils/htmlAttrSafety.ts",
|
||||
"types": "./src/utils/htmlAttrSafety.ts"
|
||||
},
|
||||
"./safe-path": {
|
||||
"bun": "./src/safePath.ts",
|
||||
"node": "./dist/safePath.js",
|
||||
"import": "./src/safePath.ts",
|
||||
"types": "./src/safePath.ts"
|
||||
},
|
||||
"./asset-paths": {
|
||||
"bun": "./src/compiler/rewriteSubCompPaths.ts",
|
||||
"node": "./dist/compiler/rewriteSubCompPaths.js",
|
||||
"import": "./src/compiler/rewriteSubCompPaths.ts",
|
||||
"types": "./src/compiler/rewriteSubCompPaths.ts"
|
||||
},
|
||||
"./runtime-script": {
|
||||
"bun": "./src/generated/runtime-inline.ts",
|
||||
"node": "./dist/generated/runtime-inline.js",
|
||||
"import": "./src/generated/runtime-inline.ts",
|
||||
"types": "./src/generated/runtime-inline.ts"
|
||||
},
|
||||
"./rich-text-sanitize": {
|
||||
"bun": "./src/utils/richTextSanitize.ts",
|
||||
"node": "./dist/utils/richTextSanitize.js",
|
||||
@@ -470,6 +488,18 @@
|
||||
"import": "./dist/utils/htmlAttrSafety.js",
|
||||
"types": "./dist/utils/htmlAttrSafety.d.ts"
|
||||
},
|
||||
"./safe-path": {
|
||||
"import": "./dist/safePath.js",
|
||||
"types": "./dist/safePath.d.ts"
|
||||
},
|
||||
"./asset-paths": {
|
||||
"import": "./dist/compiler/rewriteSubCompPaths.js",
|
||||
"types": "./dist/compiler/rewriteSubCompPaths.d.ts"
|
||||
},
|
||||
"./runtime-script": {
|
||||
"import": "./dist/generated/runtime-inline.js",
|
||||
"types": "./dist/generated/runtime-inline.d.ts"
|
||||
},
|
||||
"./rich-text-sanitize": {
|
||||
"import": "./dist/utils/richTextSanitize.js",
|
||||
"types": "./dist/utils/richTextSanitize.d.ts"
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
// @vitest-environment node
|
||||
import { readFileSync } from "node:fs";
|
||||
import { resolve } from "node:path";
|
||||
import { buildSync } from "esbuild";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
const packageDir = resolve(import.meta.dirname, "..");
|
||||
const { subpaths } = JSON.parse(readFileSync(resolve(packageDir, "package-subpaths.json"), "utf8"));
|
||||
const HEAVY = /[\\/](recast|ast-types|@babel[\\/]parser|acorn|esprima|linkedom|postcss)[\\/]/;
|
||||
|
||||
function loadedModules(entry: string): string[] {
|
||||
const { metafile } = buildSync({
|
||||
entryPoints: [resolve(packageDir, subpaths[entry].source)],
|
||||
bundle: true,
|
||||
platform: "node",
|
||||
format: "esm",
|
||||
write: false,
|
||||
metafile: true,
|
||||
logLevel: "silent",
|
||||
});
|
||||
return Object.keys(metafile.inputs);
|
||||
}
|
||||
|
||||
describe("entries a host imports for one helper", () => {
|
||||
it.each(["./safe-path", "./asset-paths"])("%s loads none of the parsers", (entry) => {
|
||||
expect(loadedModules(entry).filter((path) => HEAVY.test(path))).toEqual([]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user