I have an application that uses rollup to convert an ESM codebase to CJS before compiling it as a pkg.exe file. The issue with this is that pkg
does not allow dynamic imports, which is fine by me as there is documentation for that. When I looked deeper into the issues, seems like it’s caused by this line in the generated CJS file.
const dir = path.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('entry.js', document.baseURI).href))));
Why is rollup compiling it as require('u' + 'rl')
instead of just using require('url')
?
It’s not really a blocker on my workflow as I can just use replace-in-file
package to replace that back to 'url'
, but I’m curious as to why they did this in the first place. Performance maybe? Or something else?