Skip to content
This repository has been archived by the owner on Jan 16, 2025. It is now read-only.

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant