From fbde111f01de4398ea8f50092c7096d125333620 Mon Sep 17 00:00:00 2001 From: ajnart Date: Sat, 12 Sep 2026 23:56:54 +0200 Subject: [PATCH] fix: avoid ESM lexer imports in migration bundles --- .../custom-widgets/src/core/scoped-styles.ts | 11 ++++++++++- packages/custom-widgets/src/css-tree.d.ts | 19 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 packages/custom-widgets/src/css-tree.d.ts diff --git a/packages/custom-widgets/src/core/scoped-styles.ts b/packages/custom-widgets/src/core/scoped-styles.ts index 9ef9d8005..5e29e5cc2 100644 --- a/packages/custom-widgets/src/core/scoped-styles.ts +++ b/packages/custom-widgets/src/core/scoped-styles.ts @@ -1,4 +1,13 @@ -import { generate, ident, parse, walk } from "css-tree"; +// Consumers compile this source directly and need the modular export declarations. +// oxlint-disable-next-line typescript/triple-slash-reference +/// + +import generate from "css-tree/generator"; +import parse from "css-tree/parser"; +import { ident } from "css-tree/utils"; +import walk from "css-tree/walker"; + +// The full entrypoint loads lexer data through import.meta.url, which cannot run in bundled CJS migrations. const allowedAtRules = new Set(["media", "supports", "container", "keyframes", "-webkit-keyframes"]); const animationKeywords = new Set([ diff --git a/packages/custom-widgets/src/css-tree.d.ts b/packages/custom-widgets/src/css-tree.d.ts new file mode 100644 index 000000000..781e5d906 --- /dev/null +++ b/packages/custom-widgets/src/css-tree.d.ts @@ -0,0 +1,19 @@ +// css-tree's modular exports use the same APIs as its typed root entrypoint. +declare module "css-tree/generator" { + import { generate } from "css-tree"; + export default generate; +} + +declare module "css-tree/parser" { + import { parse } from "css-tree"; + export default parse; +} + +declare module "css-tree/utils" { + export { ident } from "css-tree"; +} + +declare module "css-tree/walker" { + import { walk } from "css-tree"; + export default walk; +}