-
- Notifications
You must be signed in to change notification settings - Fork 611
Closed
Description
- Rollup Plugin Name: @rollup/plugin-commonjs
- Rollup Plugin Version: 28
- Rollup Version: 4.34.9
- Operating System (or Browser): Windows/macOS
- Node Version: 18.20.3
- Link to reproduction (
⚠️ read below): https://stackblitz.com/edit/rollup-repro-lhjkysjm?file=server%2Frollup.config.mjs&view=editor
Expected Behavior
Build
npm run build -w serverRun
npm start -w serverxhr-sync-worker.js in jsdom should be correctly included in dynamicRequireTargets as configured.
Expected output
Hello jsdom [object Window]! Actual Behavior
Executing the output script fails with this error
Error: Cannot find module './xhr-sync-worker.js' Require stack: - /home/projects/rollup-repro-lhjkysjm/server/dist/main.js at _0x4a2c83 (https://rollupreprolhjkysjm-orah.w-corp-staticblitz.com/blitz.495c5120.js:40:21530) at internal/modules/cjs/loader/Module._resolveFilename (node:internal/modules/cjs/loader:144:12334) at resolve (node:internal/modules/helpers:163:2873) at requireXMLHttpRequestImpl (/home/projects/rollup-repro-lhjkysjm/server/dist/main.js:197494:51) at requireXMLHttpRequest/< (/home/projects/rollup-repro-lhjkysjm/server/dist/main.js:199147:16) at requireXMLHttpRequest (/home/projects/rollup-repro-lhjkysjm/server/dist/main.js:199148:4) at requireInterfaces (/home/projects/rollup-repro-lhjkysjm/server/dist/main.js:208335:20) at requireWindow (/home/projects/rollup-repro-lhjkysjm/server/dist/main.js:209876:32) at requireApi (/home/projects/rollup-repro-lhjkysjm/server/dist/main.js:210999:27) at requireMain (/home/projects/rollup-repro-lhjkysjm/server/dist/main.js:211328:20) at _0x339e27 (https://rollupreprolhjkysjm-orah.w-corp-staticblitz.com/blitz.495c5120.js:40:811403) at internal/modules/cjs/loader/Module.prototype._compile (node:internal/modules/cjs/loader:144:14246) at internal/modules/cjs/loader/Module."] (node:internal/modules/cjs/loader:144:14855) at internal/modules/cjs/loader/Module.prototype.load (node:internal/modules/cjs/loader:144:12820) at internal/modules/cjs/loader/Module._load (node:internal/modules/cjs/loader:144:10273) at executeUserEntryPoint (node:internal/modules/run_main:165:1641) at internal/main/run_main_module (node:internal/main/run_main_module:138:398) at _0x5dd822 (https://rollupreprolhjkysjm-orah.w-corp-staticblitz.com/blitz.495c5120.js:40:1444999) at executeBootstrapper (https://rollupreprolhjkysjm-orah.w-corp-staticblitz.com/blitz.495c5120.js:40:908549) at startExecution (https://rollupreprolhjkysjm-orah.w-corp-staticblitz.com/blitz.495c5120.js:40:1476481) at run (https://rollupreprolhjkysjm-orah.w-corp-staticblitz.com/blitz.495c5120.js:40:1475098) { code: 'MODULE_NOT_FOUND', requireStack: [ '/home/projects/rollup-repro-lhjkysjm/server/dist/main.js' ] } Additional Information
After going through change log and a bit of console log debugging, I realized this is caused by recent dependency change from glob -> fdir in v28. The reproduction works as expected if commonjs plugin version is changed to v27.
While absolute paths are not working anymore, based on the way fdir works, I believe currently there is no way to configure dynamicRequireTargets to include a file outside cwd (in this case server directory).
A possible solution is to add a config option to pass a root dir to crawl() here. In my case, crawl('..') works.
| .crawl() |
Metadata
Metadata
Assignees
Labels
No labels