vercel / ncc

Compile a Node.js project into a single file. Supports TypeScript, binary addons, dynamic requires.
https://npmjs.com/@vercel/ncc
MIT License
8.99k stars 285 forks source link

Error possibily related to bundling of import.meta.url #1200

Open stdavis opened 2 weeks ago

stdavis commented 2 weeks ago

I'm having strange path resolution issues with import.meta.url after it's built. I have created a simple project to reproduce the issue: https://github.com/stdavis/repros/tree/main/ncc-import-meta-url

It runs without errors before it is built. But after, I get the following error message:

node:internal/process/esm_loader:40
      internalBinding('errors').triggerUncaughtException(
                                ^

[Error: ENOTDIR: not a directory, open '/Users/***/Documents/working/repros/ncc-import-meta-url/dist/bf1263f1cc68120f8f8a.js/templates/template.hbs'] {
  errno: -20,
  code: 'ENOTDIR',
  syscall: 'open',
  path: '/Users/***/Documents/working/repros/ncc-import-meta-url/dist/bf1263f1cc68120f8f8a.js/templates/template.hbs'
}

Node.js v20.10.0

I believe that it has something to do with this code in conventional-changelog-angular. After it is built, dirname is a path to the built file, not the directory in which the module resides.

Any help would be greatly appreciated. Thanks!