Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: The 'import.meta' meta-property is only allowed when the... #1015

Open
gajus opened this issue Jan 31, 2025 · 2 comments
Open

bug: The 'import.meta' meta-property is only allowed when the... #1015

gajus opened this issue Jan 31, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@gajus
Copy link

gajus commented Jan 31, 2025

Node.js version

22

NPM version

10

@checkly/cli version

0.4.14

Steps to reproduce

  1. Use import.meta.dirname
  2. Run pnpx checkly test

What is expected?

For tests to run.

What is actually happening?

The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'.
entrypoint: path.join(import.meta.dirname, 'homepage.spec.ts')

Our tsconfig.json already uses nodenext, so it is not clear where it is picking up the other value.

Any additional comments?

No response

@gajus gajus added the bug Something isn't working label Jan 31, 2025
@sorccu
Copy link
Contributor

sorccu commented Feb 1, 2025

Hi @gajus,

I just tried it out myself and can confirm that the issue is real. The cause seems to be that we load any check files with .ts extension using ts-node here:

const tsNode = await import('ts-node')
tsCompiler = tsNode.register({
moduleTypes: {
'**/*': 'cjs',
},
compilerOptions: {
module: 'CommonJS',
},
})

As you can see it's setting module: 'CommonJS' in there, as well as forcing all moduleTypes to cjs.

To be honest I am not quite sure why it's doing that. It seems that it has always been like that, ever since it was added in #298. Some useful context can also be found in #804.

I will try to uncover some additional context about the reasoning behind this whole thing next week and figure out if we can change it.

Thanks for the report!

@gajus
Copy link
Author

gajus commented Feb 3, 2025

Can you just use something like tsx?

The latter is a lot more lenient with its inputs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants