{"_id":"@ayaseaki/swc-plugin-monorepo-relative-path-resolve","_rev":"4-c5c1ac47449cca6f0d261b6f18a12aeb","name":"@ayaseaki/swc-plugin-monorepo-relative-path-resolve","dist-tags":{"latest":"0.1.4"},"versions":{"0.1.0":{"name":"@ayaseaki/swc-plugin-monorepo-relative-path-resolve","version":"0.1.0","keywords":["swc-plugin"],"author":{"name":"Aki","email":"kirainmoe@gmail.com"},"license":"MIT","_id":"@ayaseaki/swc-plugin-monorepo-relative-path-resolve@0.1.0","maintainers":[{"name":"kirainmoe","email":"i@kirainmoe.com"}],"dist":{"shasum":"4c9a30896e61308f1e5edc1f4eebb35807d596bb","tarball":"https://registry.npmjs.org/@ayaseaki/swc-plugin-monorepo-relative-path-resolve/-/swc-plugin-monorepo-relative-path-resolve-0.1.0.tgz","fileCount":3,"integrity":"sha512-k97V10mMQpBpYmTWUBrRNWO+/CLs55dRUUhqLiueTz0Ki57llRy+YLd9GUfVfUhbe9tAT0t+5AuGRfgMpO1qMA==","signatures":[{"sig":"MEQCIAJtF/bL0iMFuRUb7hS8EcuV9L8a/hADSjBeTOcfMUuCAiBo0aRNbBygn7vOH+2BQSIG4L4JbILa+p1vab81JFw/6A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":3295034},"main":"target/wasm32-wasi/release/swc_plugin_monorepo_relative_resolve.wasm","_from":"file:ayaseaki-swc-plugin-monorepo-relative-path-resolve-0.1.0.tgz","scripts":{"build":"cargo build-wasi --release","prepublish":"pnpm build"},"_npmUser":{"name":"kirainmoe","email":"i@kirainmoe.com"},"_resolved":"C:\\Users\\Aki\\AppData\\Local\\Temp\\9e47384e4ff6a8fa3a7e4de0d2f0102a\\ayaseaki-swc-plugin-monorepo-relative-path-resolve-0.1.0.tgz","_integrity":"sha512-k97V10mMQpBpYmTWUBrRNWO+/CLs55dRUUhqLiueTz0Ki57llRy+YLd9GUfVfUhbe9tAT0t+5AuGRfgMpO1qMA==","_npmVersion":"10.2.4","description":"Resolve relative paths from sources of sub-packages in a monorepo.","directories":{},"_nodeVersion":"18.19.1","publishConfig":{"access":"public","registry":"https://registry.npmjs.org"},"_hasShrinkwrap":false,"preferUnplugged":true,"_npmOperationalInternal":{"tmp":"tmp/swc-plugin-monorepo-relative-path-resolve_0.1.0_1718799779260_0.6503853754828948","host":"s3://npm-registry-packages"}},"0.1.1":{"name":"@ayaseaki/swc-plugin-monorepo-relative-path-resolve","version":"0.1.1","keywords":["swc-plugin"],"author":{"name":"Aki","email":"kirainmoe@gmail.com"},"license":"MIT","_id":"@ayaseaki/swc-plugin-monorepo-relative-path-resolve@0.1.1","maintainers":[{"name":"kirainmoe","email":"i@kirainmoe.com"}],"dist":{"shasum":"4b0860695b9b596dc34911cb668f54367dc80afd","tarball":"https://registry.npmjs.org/@ayaseaki/swc-plugin-monorepo-relative-path-resolve/-/swc-plugin-monorepo-relative-path-resolve-0.1.1.tgz","fileCount":3,"integrity":"sha512-v4fpytD1wM51UnTAU8eTkN/3+JTmfDFdvUpei3h5+uhzF0ljgzpEXrLlRdNM0/IgSZMkN9Q6GlzByQ8zqC2f7Q==","signatures":[{"sig":"MEUCIQDKxJ50xNNYWesImBpIgir3Bin/aDXjOaO9kdnD2rFssQIgaJ5Iny3CKBLod4WgxtJTklW0poykfNsAgzI5gOlLeDs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":3295147},"main":"target/wasm32-wasi/release/swc_plugin_monorepo_relative_resolve.wasm","_from":"file:ayaseaki-swc-plugin-monorepo-relative-path-resolve-0.1.1.tgz","scripts":{"build":"cargo build-wasi --release","prepublish":"pnpm build"},"_npmUser":{"name":"kirainmoe","email":"i@kirainmoe.com"},"_resolved":"C:\\Users\\Aki\\AppData\\Local\\Temp\\da3b66e712140afb06e821943fdeaed5\\ayaseaki-swc-plugin-monorepo-relative-path-resolve-0.1.1.tgz","_integrity":"sha512-v4fpytD1wM51UnTAU8eTkN/3+JTmfDFdvUpei3h5+uhzF0ljgzpEXrLlRdNM0/IgSZMkN9Q6GlzByQ8zqC2f7Q==","_npmVersion":"10.2.4","description":"Resolve relative paths from source code of sub-packages in a monorepo.","directories":{},"_nodeVersion":"18.19.1","publishConfig":{"access":"public","registry":"https://registry.npmjs.org"},"_hasShrinkwrap":false,"preferUnplugged":true,"_npmOperationalInternal":{"tmp":"tmp/swc-plugin-monorepo-relative-path-resolve_0.1.1_1718802393002_0.1463856056945978","host":"s3://npm-registry-packages"}},"0.1.2":{"name":"@ayaseaki/swc-plugin-monorepo-relative-path-resolve","version":"0.1.2","keywords":["swc-plugin"],"author":{"name":"Aki","email":"kirainmoe@gmail.com"},"license":"MIT","_id":"@ayaseaki/swc-plugin-monorepo-relative-path-resolve@0.1.2","maintainers":[{"name":"kirainmoe","email":"i@kirainmoe.com"}],"dist":{"shasum":"4c64e84b21d27bc24450df7edc5cd2f38e2988c0","tarball":"https://registry.npmjs.org/@ayaseaki/swc-plugin-monorepo-relative-path-resolve/-/swc-plugin-monorepo-relative-path-resolve-0.1.2.tgz","fileCount":3,"integrity":"sha512-hIFY1ErAAGNxHFwQCxsjcFW4iazXNHx3aHqT3Mc4RGLE9EOjr6uXNAT0OG7CuyyAZIZmKTvyo8ZJe/IbinQp8A==","signatures":[{"sig":"MEUCIBhrZVIkK6Y2HRrWqIzv0g9LVpf7gGA0NXV9b+rsPNEQAiEAsHFRqiwvokNTcD8vjJrPJ/reRXKQ23p6qr/4PlJ0yHU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":3019173},"main":"target/wasm32-wasi/release/swc_plugin_monorepo_relative_resolve.wasm","gitHead":"94fdce2679748c78c5c0dbf978ccfba72aa2676b","scripts":{"build":"cargo build-wasi --release","prepublish":"pnpm build"},"_npmUser":{"name":"kirainmoe","email":"i@kirainmoe.com"},"_npmVersion":"10.8.2","description":"Resolve relative paths from source code of sub-packages in a monorepo.","directories":{},"_nodeVersion":"20.17.0","publishConfig":{"access":"public","registry":"https://registry.npmjs.org"},"_hasShrinkwrap":false,"preferUnplugged":true,"_npmOperationalInternal":{"tmp":"tmp/swc-plugin-monorepo-relative-path-resolve_0.1.2_1730203824320_0.7010054032434019","host":"s3://npm-registry-packages"}},"0.1.3":{"name":"@ayaseaki/swc-plugin-monorepo-relative-path-resolve","version":"0.1.3","keywords":["swc-plugin"],"author":{"name":"Aki","email":"kirainmoe@gmail.com"},"license":"MIT","_id":"@ayaseaki/swc-plugin-monorepo-relative-path-resolve@0.1.3","maintainers":[{"name":"kirainmoe","email":"i@kirainmoe.com"}],"dist":{"shasum":"f45094a70a6f7a2309504f4930f16e805ecc8cc4","tarball":"https://registry.npmjs.org/@ayaseaki/swc-plugin-monorepo-relative-path-resolve/-/swc-plugin-monorepo-relative-path-resolve-0.1.3.tgz","fileCount":3,"integrity":"sha512-O66uSJMAycxwukWiQ2dRJk5XaqsDZKKSYbj5vM+MWfRvxd1vPANNKAxNhHFI8PueJU7dF1dXn32Vab3YRLugDQ==","signatures":[{"sig":"MEQCIBZSUszKLohFQ2fV3R0psmk1Q9Tbq+z8bvYgUwqIlLUFAiADhpaQrVp5wog4gARcBAIrtN7UFbC3PJSJHF2Z9d2BBA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":1870389},"main":"target/wasm32-wasip1/release/swc_plugin_monorepo_relative_resolve.wasm","_from":"file:ayaseaki-swc-plugin-monorepo-relative-path-resolve-0.1.3.tgz","scripts":{"build":"cargo build-wasi --release","prepublish":"pnpm build"},"_npmUser":{"name":"kirainmoe","email":"i@kirainmoe.com"},"_resolved":"/private/var/folders/bl/3d75b79j0rb6fbk6ml48krv80000gn/T/5bb2686404af5c785bb1f34122abf5e2/ayaseaki-swc-plugin-monorepo-relative-path-resolve-0.1.3.tgz","_integrity":"sha512-O66uSJMAycxwukWiQ2dRJk5XaqsDZKKSYbj5vM+MWfRvxd1vPANNKAxNhHFI8PueJU7dF1dXn32Vab3YRLugDQ==","_npmVersion":"10.8.2","description":"Resolve relative paths from source code of sub-packages in a monorepo.","directories":{},"_nodeVersion":"20.18.1","publishConfig":{"access":"public","registry":"https://registry.npmjs.org"},"_hasShrinkwrap":false,"preferUnplugged":true,"_npmOperationalInternal":{"tmp":"tmp/swc-plugin-monorepo-relative-path-resolve_0.1.3_1737821151906_0.003891450063109092","host":"s3://npm-registry-packages-npm-production"}},"0.1.4":{"name":"@ayaseaki/swc-plugin-monorepo-relative-path-resolve","version":"0.1.4","description":"Resolve relative paths from source code of sub-packages in a monorepo.","author":{"name":"Aki","email":"kirainmoe@gmail.com"},"license":"MIT","keywords":["swc-plugin"],"main":"target/wasm32-wasip1/release/swc_plugin_monorepo_relative_resolve.wasm","preferUnplugged":true,"publishConfig":{"access":"public","registry":"https://registry.npmjs.org"},"scripts":{"build":"cargo build-wasi --release","prepublish":"pnpm build"},"_id":"@ayaseaki/swc-plugin-monorepo-relative-path-resolve@0.1.4","_integrity":"sha512-SPQUVbjP+FJHozeeeOhemUn+FYYXtpNGx5hoVSQT3cnJ4xefheuTJyMRW+9kaJ4sKGAd/uu5afsofRAK7cSp2g==","_resolved":"/private/var/folders/bl/3d75b79j0rb6fbk6ml48krv80000gn/T/522f11314c815ea7d0332a0f1fa3ce6c/ayaseaki-swc-plugin-monorepo-relative-path-resolve-0.1.4.tgz","_from":"file:ayaseaki-swc-plugin-monorepo-relative-path-resolve-0.1.4.tgz","_nodeVersion":"20.18.1","_npmVersion":"10.8.2","dist":{"integrity":"sha512-SPQUVbjP+FJHozeeeOhemUn+FYYXtpNGx5hoVSQT3cnJ4xefheuTJyMRW+9kaJ4sKGAd/uu5afsofRAK7cSp2g==","shasum":"f472e47a0ab4a212268a84d1d8d8bd45b7d400a8","tarball":"https://registry.npmjs.org/@ayaseaki/swc-plugin-monorepo-relative-path-resolve/-/swc-plugin-monorepo-relative-path-resolve-0.1.4.tgz","fileCount":3,"unpackedSize":1871286,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCyizKsqgGreb0OpOm4Aog1Yj9fExpu8XXXp/YjeEBK9gIhAPAXwV0Q62NDcCOhGCFB1xMojOFdSFoqEB2OMEaCCEkt"}]},"_npmUser":{"name":"kirainmoe","email":"i@kirainmoe.com"},"directories":{},"maintainers":[{"name":"kirainmoe","email":"i@kirainmoe.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/swc-plugin-monorepo-relative-path-resolve_0.1.4_1737874413289_0.7446690896925487"},"_hasShrinkwrap":false}},"time":{"created":"2024-06-19T12:22:59.151Z","modified":"2025-01-26T06:53:33.746Z","0.1.0":"2024-06-19T12:22:59.574Z","0.1.1":"2024-06-19T13:06:33.406Z","0.1.2":"2024-10-29T12:10:24.646Z","0.1.3":"2025-01-25T16:05:52.157Z","0.1.4":"2025-01-26T06:53:33.504Z"},"author":{"name":"Aki","email":"kirainmoe@gmail.com"},"license":"MIT","keywords":["swc-plugin"],"description":"Resolve relative paths from source code of sub-packages in a monorepo.","maintainers":[{"name":"kirainmoe","email":"i@kirainmoe.com"}],"readme":"# @ayaseaki/swc-plugin-monorepo-relative-path-resolve\n\nA SWC plugin to handle resolving relative import paths like `@/*` and `@common/*` of sub-packages in a monorepo.\n\n> Note: if you are building a new monorepo with path alias requirements, it is recommended to use [Node.js Subpath Imports](https://stackoverflow.com/questions/70462537/what-is-a-subpath-pattern-in-nodejs) instead of this plugin.\n\n## Why\n\nFor monorepo scene, we often have the need to directly import the source code of sub-packages to get a better bundle speed. \n\nHowever, when a sub-package in a monorepo has its own path alias defined in its `tsconfig.json`, the bundle of base app may not respect the alias config, which results in a failure of resolution:\n\n```ts\n// sub-package/src/index.ts\nimport { foo } from '@/common/constants';\nexport { foo };\n\n// sub-package/src/common/constants.ts\nexport const foo = 'foo';\n```\n\n```ts\n// base/index.ts\nimport { foo } from 'sub-package'; \nconsole.log(foo);\n\n// while compiling base/index.ts `Can't resolve @/common/constants` will be thrown\n```\n\nThis plugin aims to resolve a subset of this issue: if your alias is just a relative of `src` path, you can use this swc plugin to dynamically replace the import alias during compile-time.\n\n## Usage\n\n```bash\npnpm i -D @ayaseaki/swc-plugin-monorepo-relative-path-resolve\n```\n\nThis plugin can handle the import source matching `{prefix}{subpath}?/`. For example:\n\n- `@/*`\n- `@common/*`\n- `~common/*`\n\nUsage with rspack:\n\n```js\n// in rspack.config.js (ts):\n{\n  test: /\\.(jsx?|tsx?)$/,\n  use: [\n    {\n      loader: \"builtin:swc-loader\",\n      options: {\n        jsc: {\n          // ...\n          // add the following config:\n          experimental: {\n            plugins: [\n              [\n                \"@ayaseaki/swc-plugin-monorepo-relative-path-resolve\",\n                {\n                  prefix: \"@\",\n                  allowedPathnames: [\"common\"],\n                },\n              ],\n            ],\n          },\n        },\n      },\n    },\n  ],\n},\n```\n\nSee [example](https://github.com/kirainmoe/swc-plugin-monorepo-relative-path-resolve/tree/master/example) for detail.\n\n## Configration\n\n### prefix\n\n- type: `string`\n- description: specify the import prefix of your code.\n- default: `@`\n\n### allowedPathnames\n\n- type: `string[]`\n- description: specify the allowed pathnames after prefix, for example if you have a relative path `@common/` and `@components/`, then you set `allowedPathnames` to `['common', 'components'.]`\n- default: `[]`\n","readmeFilename":"README.md"}