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

Compile typescript from child_process fork does not work (dynamic import) #169

Open
javeoff opened this issue Dec 31, 2023 · 1 comment
Open

Comments

@javeoff
Copy link

javeoff commented Dec 31, 2023

I have typescript fork(filename) from node:child_process. When i try to run tests, I have an error Unknown file extension ".ts" for /[...myfullpath]/getSpots.ts. All imports works good but import file via fork for multithreading

jest.config.ts

import type { Config } from '@jest/types';

const config: Config.InitialOptions = {
  extensionsToTreatAsEsm: ['.ts'],
  testEnvironment: 'node',
  transform: {
    '.*\\.(tsx?)$': ['@swc/jest', {
      jsc: {
        target: "es2021",
        parser: {
          "syntax": "typescript",
          "decorators": true,
          "dynamicImport": true
        },
      },
    }],
  },
  testRegex: [
    '/tests/.*\\.(test|spec)\\.(ts)$',
    '/src/.*\\.(test|spec)\\.(ts)$',
  ],
  transformIgnorePatterns: [
    'node_modules',
    './dist',
  ],
  testPathIgnorePatterns: ['./dist'],
  moduleFileExtensions: ['ts', 'js', 'json', 'node'],
  testTimeout: 240 * 1_000,
};

export default config;


@javeoff javeoff changed the title compile typescript from child_process fork (dynamic import) Compile typescript from child_process fork does not work (dynamic import) Dec 31, 2023
@javeoff
Copy link
Author

javeoff commented Jan 2, 2024

It also doesnt work with node:worker_threads

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant