From a5b0c07f15022c1afba817e6294191e6f8177328 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Thu, 25 Apr 2024 17:08:31 +0100 Subject: [PATCH] Remove dependency on node:module Should allow this package to be used in non-node environments. Resolves #20 --- src/index.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index f1ee00a..7b06ccb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,10 +1,12 @@ import type * as Babel from "@babel/core"; import type { types as t, NodePath } from "@babel/core"; -import { createRequire } from "node:module"; import { ImportUtil } from "babel-import-util"; import { globalId } from "./global-id.ts"; -const req = createRequire(import.meta.url); -const { default: decoratorSyntax } = req("@babel/plugin-syntax-decorators"); + +// @ts-expect-error no upstream types +import PluginSyntaxDecorators from "@babel/plugin-syntax-decorators"; +const decoratorSyntax = + PluginSyntaxDecorators.default || PluginSyntaxDecorators; interface State extends Babel.PluginPass { currentClassBodies: t.ClassBody[];