Skip to content
This repository has been archived by the owner on Oct 18, 2023. It is now read-only.

Commit

Permalink
perf: remove unused code & dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
privatenumber committed Jun 7, 2022
1 parent 85e27f5 commit 2318a38
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 36 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
},
"dependencies": {
"@esbuild-kit/core-utils": "^1.2.1",
"es-module-lexer": "^0.10.5",
"get-tsconfig": "^3.0.1"
},
"devDependencies": {
Expand Down
6 changes: 0 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 0 additions & 29 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import path from 'path';
import { init, parse } from 'es-module-lexer';

export const tsExtensionsPattern = /\.([cm]?ts|[tj]sx)$/;

Expand All @@ -24,31 +23,3 @@ export type ModuleFormat =
| 'wasm';

export type MaybePromise<T> = T | Promise<T>;

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);
}

0 comments on commit 2318a38

Please sign in to comment.