{"id":10654,"library":"common-js-file-extensions","title":"Common JavaScript File Extensions","description":"The `common-js-file-extensions` package provides two static arrays, `code` and `config`, listing various file extensions associated with JavaScript code and configuration files, respectively. It includes extensions for a wide range of JavaScript dialects and transpiled languages, such as standard `.js`, `.mjs`, `.cjs`, as well as older or less common ones like `.coffee`, `.ts`, `.iced`, `.es6`, `.jsx`, and `.json5`. Currently at version 1.0.4, the package appears to be stable but likely no longer actively maintained, given its last update years ago (copyright 2016). Its primary utility lies in offering a comprehensive, if somewhat dated, reference for tools needing to identify JavaScript-related files without needing to parse package manifests or project configurations for specific language tooling.","status":"abandoned","version":"1.0.4","language":"javascript","source_language":"en","source_url":"https://github.com/luislobo/common-js-file-extensions","tags":["javascript","js","extensions","file","extension","name"],"install":[{"cmd":"npm install common-js-file-extensions","lang":"bash","label":"npm"},{"cmd":"yarn add common-js-file-extensions","lang":"bash","label":"yarn"},{"cmd":"pnpm add common-js-file-extensions","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is a CommonJS module. For ES Modules, import the default object and destructure it.","wrong":"import { code, config } from 'common-js-file-extensions';","symbol":"code, config","correct":"const { code, config } = require('common-js-file-extensions');"},{"note":"When importing a CommonJS module into an ES Module context, the module's exports object becomes the default export. Using `import * as` might work in some bundlers but is not the standard Node.js behavior.","wrong":"import * as extensions from 'common-js-file-extensions';","symbol":"All exports as default","correct":"import extensions from 'common-js-file-extensions';\nconst { code, config } = extensions;"}],"quickstart":{"code":"const { code, config } = require('common-js-file-extensions');\n\nconsole.log('--- JavaScript Code File Extensions ---');\ncode.forEach(ext => console.log(`  .${ext}`));\n\nconsole.log('\\n--- JavaScript Config/Object File Extensions ---');\nconfig.forEach(ext => console.log(`  .${ext}`));\n\n// Example of checking a file extension\nconst fileName = 'my-component.tsx';\nconst fileExtension = fileName.split('.').pop();\n\nif (fileExtension && code.includes(fileExtension)) {\n  console.log(`\\n'${fileName}' is a known JavaScript code file.`);\n} else if (fileExtension && config.includes(fileExtension)) {\n  console.log(`\\n'${fileName}' is a known JavaScript config/object file.`);\n} else {\n  console.log(`\\n'${fileName}' is not recognized as a common JS file type.`);\n}","lang":"javascript","description":"Demonstrates how to import the `code` and `config` arrays and iterate through the listed extensions. It also includes a basic example of checking a file's extension against these lists."},"warnings":[{"fix":"For ES Modules, use `import extensions from 'common-js-file-extensions'; const { code, config } = extensions;`. For CommonJS, `const { code, config } = require('common-js-file-extensions');` is correct.","message":"This package is explicitly a CommonJS module. While it can be imported into an ES Module (ESM) context, direct named imports (`import { code } from 'pkg'`) will not work as expected in Node.js, often resulting in `undefined` or runtime errors. ESM users must import the module's default export (which is the CommonJS `module.exports` object) and destructure from that.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Developers should filter or curate the `code` and `config` arrays to include only the extensions relevant to their specific project or environment if broad inclusion is not desired.","message":"The package includes a very comprehensive list of extensions, encompassing many older, niche, or less common JavaScript dialects and transpilers (e.g., IcedCoffeeScript, Stratified JavaScript, LiveScript, Earl Grey). While thorough, this breadth might not be relevant for most modern JavaScript projects and could lead to over-inclusive file scanning or unnecessary complexity if used without filtering.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"For applications requiring an up-to-date list of JavaScript file extensions, consider manually curating a list or finding a more actively maintained library, though for its specific historical data, this package remains functional.","message":"The package has not seen updates since its initial releases around 2016 (indicated by copyright and versioning). This suggests it is no longer actively maintained. While its static data is unlikely to 'break', new or evolving JavaScript file extensions (e.g., future TypeScript or JSX variants, or new bundler-specific extensions) will not be added.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Import the module's default export first, then destructure from it: `import extensions from 'common-js-file-extensions'; const { code, config } = extensions;`","cause":"Attempting a named ES Module import (`import { code } from 'common-js-file-extensions';`) of a CommonJS module in a Node.js ESM environment.","error":"TypeError: Cannot destructure property 'code' of 'common_js_file_extensions_1' as it is undefined."},{"fix":"If your project is ESM-first, use `import` syntax: `import extensions from 'common-js-file-extensions'; const { code, config } = extensions;`. If you must use `require` in an ESM file, you might need to use `createRequire` from the `module` built-in module, but it's generally recommended to stick to `import`.","cause":"Attempting to use `require()` syntax in an ES Module (ESM) file without proper transpilation or configuration.","error":"ReferenceError: require is not defined"}],"ecosystem":"npm"}