{"id":16847499,"url":"https://github.com/fabiosantoscode/scatterbrain","last_synced_at":"2025-03-18T07:17:22.714Z","repository":{"id":39606844,"uuid":"282071981","full_name":"fabiosantoscode/scatterbrain","owner":"fabiosantoscode","description":null,"archived":false,"fork":false,"pushed_at":"2022-12-30T20:54:46.000Z","size":809,"stargazers_count":0,"open_issues_count":14,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-27T16:59:11.283Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fabiosantoscode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-23T22:45:09.000Z","updated_at":"2020-07-23T22:45:57.000Z","dependencies_parsed_at":"2023-01-31T16:31:18.533Z","dependency_job_id":null,"html_url":"https://github.com/fabiosantoscode/scatterbrain","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabiosantoscode%2Fscatterbrain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabiosantoscode%2Fscatterbrain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabiosantoscode%2Fscatterbrain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabiosantoscode%2Fscatterbrain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fabiosantoscode","download_url":"https://codeload.github.com/fabiosantoscode/scatterbrain/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244173553,"owners_count":20410300,"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":[],"created_at":"2024-10-13T13:08:09.798Z","updated_at":"2025-03-18T07:17:22.693Z","avatar_url":"https://github.com/fabiosantoscode.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Scatterbrain\n\nScatterbrain is a package which helps you configure your preferred flavour of JavaScript with multiple tools.\n\nThe interface is the same as has been developed recently for node.js, which is still experimental and may change. The point is to enable your code to run on node and all other platforms at once.\n\n## Motivation\n\nUsing a language other than JavaScript has never been exactly easy in a node project, especially one which also has a web component.\n\nYou need to:\n\n * Configure how transpilation works for each extension\n * Configure how to resolve files, in case you use aliases or drop-in replacements like `react-native`\n\nAnd once you do configure that for node, eslint, prettier, webpack, jest, mocha, or any other tool which needs to read and/or run your code, every time you add a new tool or language, you have to painstakingly configure it from scratch.\n\nThe JS community has had scatterbrain for long enough.\n\n## Configuration\n\nYou configure your nodejs runtime using package.json, which allows you to use `import` and absolute imports in plain old NodeJS (if you wish to use NodeJS).\n\n```json\n{\n  \"type\": \"module\",\n  \"imports\": {\n    \"#lib/\": \"./lib\"\n  }\n}\n```\n\n*SOON:* scatterbrain will support the [experimental loaders API](https://nodejs.org/api/esm.html#esm_experimental_loaders).\n\n## Webpack\n\nTo configure webpack, grab `scatterbrain/webpack` and insert its adapters into your config as such:\n\nwebpack.config.js:\n\n```javascript\nconst rootPath = __dirname // Path to where package.json is\nconst packageJson = require('./package.json')\nconst scatterbrain = require('scatterbrain/webpack')\n\nmodule.exports = {\n  module: {\n    rules: [\n      scatterbrain.rule(rootPath, packageJson)\n    ]\n  },\n  resolve: {\n    alias: scatterbrain.aliases(rootPath, packageJson)\n  }\n}\n```\n\n## Jest\n\njest.config.js:\n\n```\nconst rootPath = __dirname // Path to where package.json is\nconst packageJson = require('./package.json')\nconst scatterbrain = require('scatterbrain/jest')\n\nmodule.exports = {\n  moduleNameMapper: {\n    ...scatterbrain.moduleNameMapper(rootPath, packageJson)\n  }\n}\n```\n\n## Roadmap\n\n - Implement adapters for as many tools as possible\n - Transpile JavaScript according to [experimental loaders API](https://nodejs.org/api/esm.html#esm_experimental_loaders).\n - Use a shared synchronised compilation cache\n - Provide a way to replace modules with drop-in replacements (possibly with config :( )\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffabiosantoscode%2Fscatterbrain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffabiosantoscode%2Fscatterbrain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffabiosantoscode%2Fscatterbrain/lists"}