{"_id":"@ayan4m1/gatsby-plugin-root-import","_rev":"2-55d340919f6f2cd902969caa256c022b","name":"@ayan4m1/gatsby-plugin-root-import","dist-tags":{"latest":"2.0.11"},"versions":{"2.0.10":{"name":"@ayan4m1/gatsby-plugin-root-import","version":"2.0.10","keywords":["gatsby","gatsby-plugin","import","root"],"author":{"name":"Mong-Kuen Sun","email":"mongkuen.sun@gmail.com"},"license":"MIT","_id":"@ayan4m1/gatsby-plugin-root-import@2.0.10","maintainers":[{"name":"ayan4m1","email":"andrew@bulletlogic.com"}],"contributors":[{"name":"ayan4m1","email":"andrew@bulletlogic.com"}],"homepage":"https://github.com/ayan4m1/gatsby-plugin-root-import","bugs":{"url":"https://github.com/ayan4m1/gatsby-plugin-root-import/issues"},"dist":{"shasum":"e76e2bba2db59773a7c29ec9718dc31dcbde97ec","tarball":"https://registry.npmjs.org/@ayan4m1/gatsby-plugin-root-import/-/gatsby-plugin-root-import-2.0.10.tgz","fileCount":10,"integrity":"sha512-Now6pVcLPuCKexuBuwiUsZ4FTtB06iplmj6VcPN2jIt4cP0HvQqFnESzrJOO6g9lhWuQpUEyynWAQFiZRcoGpA==","signatures":[{"sig":"MEUCIQCNG9NCBBqaOVarg6u0ocfImwuLctZs+++FdSvQNnmXeQIgJni5AsbAxGWuYsQAK5+gowQBqy9O+nHkaZveURBzGj0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":6909},"main":"index.js","gitHead":"8c18043fb1c8a313c67e17282bdff2ff411903fe","scripts":{"dev":"onchange \"src/**/*.js\" -- npm run build","build":"babel src --out-dir .","prepublishOnly":"npm run build"},"_npmUser":{"name":"ayan4m1","email":"andrew@bulletlogic.com"},"repository":{"url":"git+https://github.com/ayan4m1/gatsby-plugin-root-import.git","type":"git"},"_npmVersion":"10.8.2","description":"Gatsby plugin to set Webpack to resolve import root","directories":{},"_nodeVersion":"20.17.0","_hasShrinkwrap":false,"devDependencies":{"husky":"^9.1.6","onchange":"^7.1.0","prettier":"^3.3.3","@babel/cli":"^7.25.6","@babel/core":"^7.25.2","lint-staged":"^15.2.10","babel-preset-gatsby-package":"^3.13.1"},"peerDependencies":{"gatsby":"^2 || ^3 || ^4 || ^5"},"_npmOperationalInternal":{"tmp":"tmp/gatsby-plugin-root-import_2.0.10_1727271108917_0.6500088483128625","host":"s3://npm-registry-packages"}},"2.0.11":{"name":"@ayan4m1/gatsby-plugin-root-import","description":"Gatsby plugin to set Webpack to resolve import root","version":"2.0.11","license":"MIT","author":{"name":"Mong-Kuen Sun","email":"mongkuen.sun@gmail.com"},"contributors":[{"name":"ayan4m1","email":"andrew@bulletlogic.com"}],"homepage":"https://github.com/ayan4m1/gatsby-plugin-root-import","bugs":{"url":"https://github.com/ayan4m1/gatsby-plugin-root-import/issues"},"repository":{"type":"git","url":"git+https://github.com/ayan4m1/gatsby-plugin-root-import.git"},"keywords":["gatsby","gatsby-plugin","import","root"],"main":"index.js","scripts":{"dev":"onchange \"src/**/*.js\" -- npm run build","build":"babel src --out-dir .","prepublishOnly":"npm run build"},"devDependencies":{"@babel/cli":"^7.28.6","@babel/core":"^7.29.0","babel-preset-gatsby-package":"^3.16.0","husky":"^9.1.7","lint-staged":"^16.4.0","onchange":"^7.1.0","prettier":"^3.8.3"},"peerDependencies":{"gatsby":"^2 || ^3 || ^4 || ^5"},"gitHead":"aac5d8283bec7f05b8d96dd50e1247c98cfd87a3","_id":"@ayan4m1/gatsby-plugin-root-import@2.0.11","_nodeVersion":"24.14.1","_npmVersion":"11.11.0","dist":{"integrity":"sha512-SnN5S4e0AlwI07s2xOKrTfaBgWbqdP7ar+1gsSwUIsoU0vqxdZzT0PYXn/UESxC1CZpyb6nX/KxQCtWqxZCG0Q==","shasum":"50cecb7fe229723bfb9bbcf4623f2a3cc34b105f","tarball":"https://registry.npmjs.org/@ayan4m1/gatsby-plugin-root-import/-/gatsby-plugin-root-import-2.0.11.tgz","fileCount":10,"unpackedSize":6908,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIQCccZyNYkpkL2I9L3Og5/zBBuWQowafMR3/A5GcG9B6vgIfB2VRo9AmegIBZJbwPf8Ko4kwPYi/VkrodKVNbdNWfQ=="}]},"_npmUser":{"name":"ayan4m1","email":"andrew@bulletlogic.com"},"directories":{},"maintainers":[{"name":"ayan4m1","email":"andrew@bulletlogic.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/gatsby-plugin-root-import_2.0.11_1777855436167_0.14734427132077776"},"_hasShrinkwrap":false}},"time":{"created":"2024-09-25T13:31:48.837Z","modified":"2026-05-04T00:43:56.416Z","2.0.10":"2024-09-25T13:31:49.097Z","2.0.11":"2026-05-04T00:43:56.290Z"},"bugs":{"url":"https://github.com/ayan4m1/gatsby-plugin-root-import/issues"},"author":{"name":"Mong-Kuen Sun","email":"mongkuen.sun@gmail.com"},"license":"MIT","homepage":"https://github.com/ayan4m1/gatsby-plugin-root-import","keywords":["gatsby","gatsby-plugin","import","root"],"repository":{"type":"git","url":"git+https://github.com/ayan4m1/gatsby-plugin-root-import.git"},"description":"Gatsby plugin to set Webpack to resolve import root","contributors":[{"name":"ayan4m1","email":"andrew@bulletlogic.com"}],"maintainers":[{"name":"ayan4m1","email":"andrew@bulletlogic.com"}],"readme":"# @ayan4m1/gatsby-plugin-root-import\n\nSet Webpack to resolve modules and aliases, allowing you to import modules from an absolute project path rather than relative `../../` paths.\n\n### Install\n\n1. Install the `@ayan4m1/gatsby-plugin-root-import` plugin:\n\n   `npm install --save-dev @ayan4m1/gatsby-plugin-root-import`\n\n   or\n\n   `yarn add --dev @ayan4m1/gatsby-plugin-root-import`\n\n### Usage\n\nAdd into `gatsby-config.js`.\n\n```javascript\n// gatsby-config.js\n\nmodule.exports = {\n  plugins: ['@ayan4m1/gatsby-plugin-root-import']\n};\n```\n\n### Default Settings\n\nIf no options are specified, the plugin allows you access to the `src` folder and also it's contents automatically.\n\nThis means you should be able to import modules like such:\n\n```javascript\n// importing gatsbyProject/src/someFolder/SomeComponent.js\n\nimport SomeComponent from 'src/someFolder/SomeComponent';\n// or more succinctly\nimport SomeComponent from 'someFolder/SomeComponent';\n```\n\n### Plugin Options\n\nPlugin Options allows you to:\n\n1. Specify additional webpack [`resolve.modules`](https://webpack.js.org/configuration/resolve/#resolvemodules) search locations with the `resolveModules` key.\n2. All other option keys will become a Webpack [`alias`](https://webpack.js.org/configuration/resolve/#resolvealias).\n\n```javascript\n// gatsby-config.js\nconst path = require('path');\n\nmodule.exports = {\n  plugins: [\n    {\n      resolve: '@ayan4m1/gatsby-plugin-root-import',\n      options: {\n        resolveModules: [path.join(__dirname, 'libs')],\n        utils: path.join(__dirname, 'src', 'components', 'utilities')\n      }\n    }\n  ]\n};\n```\n\nThis means you should be able to import modules like such:\n\n```javascript\n// gatsbyProject/libs is now a searched resolve.modules directory\n// importing gatsbybProject/libs/someLib/SomeLibComponent.js\nimport SomeLibComponent from 'someLib/SomeLibComponent';\n\n// from the 'utils' alias\n// importing gatsbyProject/src/components/utilities/UtilityComponent.js\nimport UtilityComponent from 'utils/UtilityComponent';\n```\n\n### Jest testing\n\nThe new aliased paths lets Webpack correctly compile your app. However this does not mean that Jest, or other test runners will understand where those aliases point to.\n\nWhen setting up testing with Jest, see [`moduleNameMapper`](https://jestjs.io/docs/en/configuration.html#modulenamemapper-objectstring-string--arraystring) to correctly map your your aliases to a path that Jest can understand.\n\nFor example:\n\n```javascript\n// gatsby-config.js\nconst path = require('path');\n\nmodule.exports = {\n  // ...other configs\n  plugins: [\n    {\n      resolve: '@ayan4m1/gatsby-plugin-root-import',\n      options: {\n        components: path.join(__dirname, 'src', 'web', 'components')\n      }\n    }\n  ]\n};\n```\n\ncould work with a Jest map like:\n\n```javascript\n// jest.config.js\nmodule.exports = {\n  // ...other configs\n  moduleNameMapper: {\n    '^components/(.*)': '<rootDir>/src/web/components/$1'\n  }\n};\n```\n\nPlease see Jest's [`moduleNameMapper`](https://jestjs.io/docs/en/configuration.html#modulenamemapper-objectstring-string--arraystring) documentation for specific implementation details regarding format and options.\n","readmeFilename":"README.md"}