{"id":17216309,"url":"https://github.com/ganeshkbhat/get-isesm","last_synced_at":"2025-04-13T23:21:08.145Z","repository":{"id":62248523,"uuid":"559104159","full_name":"ganeshkbhat/get-isesm","owner":"ganeshkbhat","description":"The module has JS functions to check all imports or required modules and check if the file is a ES Module or a CJS/ JS Module or Script","archived":false,"fork":false,"pushed_at":"2023-01-27T04:13:59.000Z","size":684,"stargazers_count":5,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-25T19:05:21.774Z","etag":null,"topics":["cjs","es","esm","iscjscode","isescode","js","module"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ganeshkbhat.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-10-29T04:21:05.000Z","updated_at":"2023-12-06T18:22:46.000Z","dependencies_parsed_at":"2023-02-15T05:01:00.732Z","dependency_job_id":null,"html_url":"https://github.com/ganeshkbhat/get-isesm","commit_stats":null,"previous_names":["ganeshkbhat/isesm"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ganeshkbhat%2Fget-isesm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ganeshkbhat%2Fget-isesm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ganeshkbhat%2Fget-isesm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ganeshkbhat%2Fget-isesm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ganeshkbhat","download_url":"https://codeload.github.com/ganeshkbhat/get-isesm/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248794947,"owners_count":21162683,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cjs","es","esm","iscjscode","isescode","js","module"],"created_at":"2024-10-15T03:27:26.786Z","updated_at":"2025-04-13T23:21:08.120Z","avatar_url":"https://github.com/ganeshkbhat.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# check-esm\nModule to fetch all required and imported modules in Javascript and NodeJS. The module has JS functions to check all imports or required modules and check if the file is a ES Module or a CJS/ JS Module or Script\n\nFind the demos in the [demos folder](./demos)\n\n\n---\n\n\n### INSTALL\n\n```npm install check-esm --save```\n\n\n---\n\n\n### USAGE\n\n\nESM Module\n\n`import { _isESCode } from \"check-esm\";`\n\n\nCommonJS Script/ Module\n\n```\nconst checkEsm = require(\"check-esm\");`\nisESCode(\"./path/to/file.mjs\")\n```\n\n\n[Simple Medium blog for usage] (https://medium.com/@ganeshsurfs/exploring-node-js-and-js-checking-is-a-package-is-a-commonjs-script-module-or-a-esm-module-2847c456d93f)\n\n\n---\n\n\n### Package APIs\n\n\nThere are other script APIs you may wish to explore that includes the following:\n\n#### `.checkModuleImports` \nCheck if a module can be imported using `import()`\n\nUsage:\n\n`.checkModuleImports(absPath)`\n\n\n\n#### `.requiresObject`\nCheck require.cache list in code - used in your code's process global context.\n\nUsage:\n\n`.requiresObject()`\n\n\n\n#### `.requireRegex`\nCheck to see if there are `require()` syntax in code.\n\nUsage:\n\n`.requireRegex(absPath, basePath = \"\", useProcessCwd = false)`\n\n`.requireRegex(absPath)`\n\n\n\n#### `.importRegex`\nCheck to see if there are `import()` syntax in code.\n\nUsage:\n\n`.importRegex(absPath, basePath = \"\", useProcessCwd = false)`\n\n`.importRegex(absPath)`\n\n\n\n#### `.importESRegex`\nCheck to see if there are `import x from \"\"` syntax in code.\n\nUsage:\n\n`.importESRegex(absPath, basePath = \"\", useProcessCwd = false)`\n\n`.importESRegex(absPath)`\n\n\n\n#### `.importRegexExtended`\nCheck to see if there are `import()` syntax in code.\n\nUsage:\n\n`.importRegexExtended(absPath, basePath = \"\", useProcessCwd = false)`\n\n`.importRegexExtended(absPath)`\n\n\n\n#### `.isESMFileExtension`\nCheck to see if the file has `.mjs`/ `.cjs`/ `.js` extension.\n\nUsage:\n\n`.isESMFileExtension(absPath)`\n\n\n\n#### `.isNodeCompatibleFileExtension`\nCheck to see if the file has `.mjs`/ `.cjs`/ `.js` / `.node` / `.wasm` extension.\n\nUsage:\n\n`.isNodeCompatibleFileExtension(absPath)`\n\n\n\n#### `.isESMCodeBase`\nCheck to see if the code is ESM Module.\n\nUsage:\n\n`.isESMCodeBase(absPath)`\n\n\n\n#### `isCJSCodeBase`\nCheck to see if the code is CommonJS Script or Module.\n\nUsage:\n\n`isCJSCodeBase(absPath)`\n\n\n\n#### `isModuleInPackageJson`\nChecks type key's value in package.json.\n\nUsage:\n\n`getPackageJsonRoot(startdirectory, options)`\n\n\n\n#### `isESCode`\nMultiple checks to check if the code is ESM Module (other than package.json type key's value check in package.json).\n\nUsage:\n\n`isModuleInPackageJson(absPath, packagejsonPath, returns)`\n\n\n---\n\n\n\n### Contributions\n\nContributions, Feature Improvements, Bugs, and Issues are invited. [raising an issue](https://github.com/ganeshkbhat/get-isesm/issues)\n\n\n# License\n\n[MIT License](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fganeshkbhat%2Fget-isesm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fganeshkbhat%2Fget-isesm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fganeshkbhat%2Fget-isesm/lists"}