{"id":21146355,"url":"https://github.com/bhallstein/rollup-plugin-commonjs-dynamicrequireroot-symlink-issue","last_synced_at":"2026-07-17T18:35:08.707Z","repository":{"id":143863516,"uuid":"590856658","full_name":"bhallstein/rollup-plugin-commonjs-dynamicrequireroot-symlink-issue","owner":"bhallstein","description":"Reproduction of @rollup/plugin-commonjs dynamicRequireRoot symlink issue","archived":false,"fork":false,"pushed_at":"2023-01-19T11:40:46.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"int","last_synced_at":"2025-10-20T01:50:52.005Z","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/bhallstein.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-19T11:27:43.000Z","updated_at":"2023-01-19T11:27:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"b5b92053-625a-429f-8479-3e00a5fa2776","html_url":"https://github.com/bhallstein/rollup-plugin-commonjs-dynamicrequireroot-symlink-issue","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bhallstein/rollup-plugin-commonjs-dynamicrequireroot-symlink-issue","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bhallstein%2Frollup-plugin-commonjs-dynamicrequireroot-symlink-issue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bhallstein%2Frollup-plugin-commonjs-dynamicrequireroot-symlink-issue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bhallstein%2Frollup-plugin-commonjs-dynamicrequireroot-symlink-issue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bhallstein%2Frollup-plugin-commonjs-dynamicrequireroot-symlink-issue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bhallstein","download_url":"https://codeload.github.com/bhallstein/rollup-plugin-commonjs-dynamicrequireroot-symlink-issue/tar.gz/refs/heads/int","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bhallstein%2Frollup-plugin-commonjs-dynamicrequireroot-symlink-issue/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35592242,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-17T02:00:06.162Z","response_time":116,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-11-20T08:53:03.063Z","updated_at":"2026-07-17T18:35:08.641Z","avatar_url":"https://github.com/bhallstein.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## @rollup/plugin-commonjs dynamicRequireRoot issue reproduction\n\nIssue found when using @rollup/plugin-commonjs with dynamicRequireTargets/dynamicRequireRoot and a symlinked app directory.\n\nOutline of files in project:\n```\n/folder/my-app                 - contains the app to be compiled\n/folder/my-app/my-app.js\n/folder/my-app/package.json\n/folder/my-app/node_modules\n\n/build.sh\n/package.json\n/rollup.config.js\n```\n\nTo build:\n```sh\nbash build.sj\n```\n\nDuring build, build.sh first creates a symlink `/my-app -\u003e /folder/my-app`, then invokes rollup, which takes `/my-app/my-app.js` as the input file.\n\n\n### Expected behaviour\n\nThe require root should be correctly identified as a valid parent of the compiled file(s).\n\nIdeally this should occur regardless of whether the require root is expanded from its symlink form or not.\n\n\n### Issue\n\nTo reproduce both cases, run `bash build.sh` with `dynamicRequireRoot` in rollup.config.js set to either of the example lines located there.\n\n#### 1. dynamicRequireRoot: 'my-app/node_modules'\n\nHere the require root is `my-app/node_modules`. Error produced:\n\n_[!] (plugin commonjs--resolver) RollupError: \"/Users/ben/Desktop/rollup-plugin-commonjs-dynamicrequireroot-symlink-issue/folder/my-app/node_modules/sequelize/lib/dialects/abstract/connection-manager.js\" contains dynamic require statements but it is not within the current dynamicRequireRoot \"/Users/ben/Desktop/rollup-plugin-commonjs-dynamicrequireroot-symlink-issue/my-app/node_modules\". You should set dynamicRequireRoot to \"/Users/ben/Desktop/rollup-plugin-commonjs-dynamicrequireroot-symlink-issue/folder/my-app/node_modules/sequelize/lib/dialects/abstract\" or one of its parent directories._\n\n- The error is saying that the file's path is `folder/my-app/node_modules/sequelize/lib/dialects/abstract/connection-manager.js` — i.e. the file path is fully expanded from the symlink.\n- It complains that `my-app/node_modules` is not a parent of `my-app/node_modules/.../\u003cfile\u003e.js`.\n- It suggests setting the require root to `folder/my-app/node_modules` instead, as this would be a valid parent of the file path as stated.\n\n#### 2. dynamicRequireRoot: realpathSync('my-app') + '/node_modules'\n\nHere the require root is `folder/my-app/node_modules` — the expanded form as asked for in the above error. Error produced:\n\n_[!] (plugin commonjs) RollupError: \"/Users/ben/Desktop/rollup-plugin-commonjs-dynamicrequireroot-symlink-issue/my-app/node_modules/sequelize/lib/dialects/abstract/connection-manager.js\" contains dynamic require statements but it is not within the current dynamicRequireRoot \"/Users/ben/Desktop/rollup-plugin-commonjs-dynamicrequireroot-symlink-issue/folder/my-app/node_modules\". You should set dynamicRequireRoot to \"/Users/ben/Desktop/rollup-plugin-commonjs-dynamicrequireroot-symlink-issue/my-app/node_modules/sequelize/lib/dialects/abstract\" or one of its parent directories._\n- i.e. it is now stating the file path as `my-app/node_modules/sequelize/lib/dialects/abstract/connection-manager.js` — i.e. the non-expanded form.\n- Rollup now makes the opposite complaint, i.e. that `folder/my-app/node_modules` is not a parent of `my-app/node_modules/.../\u003cfile\u003e.js`\n\nTo summarise: It's a catch-22:\n\n- dynamicRequireRoot non-expanded: rollup says `\u003cnon-expanded require root path\u003e` is not a parent of `\u003cexpanded file path\u003e`.\n- dynamicRequireRoot expanded: rollup says: `\u003cexpanded require root path\u003e` is not a parent of `\u003cnon-expanded file path\u003e`.\n\ni.e.: curiously, when dynamicRequireRoot changes between expanded/non-expanded, the file path is considered non-expanded/expanded (i.e. the opposite) which seems to creates a conflict whatever you do.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbhallstein%2Frollup-plugin-commonjs-dynamicrequireroot-symlink-issue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbhallstein%2Frollup-plugin-commonjs-dynamicrequireroot-symlink-issue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbhallstein%2Frollup-plugin-commonjs-dynamicrequireroot-symlink-issue/lists"}