Skip to content

ESM required from CJS is missing import.meta props (works fine in Node 20) #744

@patrickshipe

Description

@patrickshipe

Acknowledgements

  • I read the documentation and searched existing issues to avoid duplicates
  • I understand this is a bug tracker and anything other than a proven bug will be closed
  • I understand this is a free project and relies on community contributions
  • I read and understood the Contribution guide

Minimal reproduction URL

https://stackblitz.com/edit/node-8eez9hly?file=package.json

Problem & expected behavior (under 200 words)

If you run npm run start (e.g. run tsx index.js), you will see that the ESM file required from the CJS passthrough logs {} from import.meta:

> @ start /home/projects/node-8eez9hly
> tsx index.js

Logging import meta from the CJS passthrough!
Import meta: {}

If you use regular Node via npm run start:node (e.g. node index.js), you will see:

> start:node
> node index.js

Logging import meta from the CJS passthrough!
Import meta: [Object: null prototype] {
  dirname: '/home/projects/node-8eez9hly',
  filename: '/home/projects/node-8eez9hly/logImportMeta.js',
  resolve: [Function: resolve],
  url: 'file:///home/projects/node-8eez9hly/logImportMeta.js'
}

Bugs are expected to be fixed by those affected by it

  • I'm interested in working on this issue

Compensating engineering work will speed up resolution and support the project

  • I'm willing to offer $10 for financial support

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions