diff --git a/package.json b/package.json index a17f208..80f43da 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,6 @@ }, "dependencies": { "@esbuild-kit/core-utils": "^1.2.1", - "es-module-lexer": "^0.10.5", "get-tsconfig": "^3.0.1" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 45275e1..a9feb44 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5,7 +5,6 @@ specifiers: '@pvtnbr/eslint-config': ^0.22.0 '@types/node': ^17.0.33 '@types/semver': ^7.3.9 - es-module-lexer: ^0.10.5 eslint: ^8.15.0 execa: ^6.1.0 get-node: ^13.0.1 @@ -18,7 +17,6 @@ specifiers: dependencies: '@esbuild-kit/core-utils': 1.2.1 - es-module-lexer: 0.10.5 get-tsconfig: 3.0.1 devDependencies: @@ -940,10 +938,6 @@ packages: unbox-primitive: 1.0.2 dev: true - /es-module-lexer/0.10.5: - resolution: {integrity: sha512-+7IwY/kiGAacQfY+YBhKMvEmyAJnw5grTUgjG85Pe7vcUI/6b7pZjZG8nQ7+48YhzEAEqrEgD2dCz/JIK+AYvw==} - dev: false - /es-shim-unscopables/1.0.0: resolution: {integrity: sha512-Jm6GPcCdC30eMLbZ2x8z2WuRwAws3zTBBKuusffYVUrNj/GVSUAZ+xKMaUpfNDR5IbyNA5LJbaecoUVbmUcB1w==} dependencies: diff --git a/src/utils.ts b/src/utils.ts index 88e3983..ce299ea 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,5 +1,4 @@ import path from 'path'; -import { init, parse } from 'es-module-lexer'; export const tsExtensionsPattern = /\.([cm]?ts|[tj]sx)$/; @@ -24,31 +23,3 @@ export type ModuleFormat = | 'wasm'; export type MaybePromise = T | Promise; - -let isLexerReady = false; - -// eslint-disable-next-line promise/catch-or-return -init.then(() => { - isLexerReady = true; -}); - -/** - * isESM - determined by whether the module - * uses imports or exports - */ -const _isEsm = (source: string) => { - const [imports, exports] = parse(source); - - return ( - imports.length > 0 - || exports.length > 0 - ); -}; - -export function isEsm(source: string) { - if (!isLexerReady) { - return init.then(() => _isEsm(source)); - } - - return _isEsm(source); -}