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

tsconfig.json includes from node_modules not rewritten #3281

Closed
robaca opened this issue Nov 26, 2021 · 2 comments · Fixed by #3293
Closed

tsconfig.json includes from node_modules not rewritten #3281

robaca opened this issue Nov 26, 2021 · 2 comments · Fixed by #3293
Labels
🐛 Bug Something isn't working

Comments

@robaca
Copy link

robaca commented Nov 26, 2021

Currently we are referencing d.ts types from a shared library in our local projects like here:

{
    "extends": "../../../tsconfig-base.json",
    "compilerOptions": {
        "target": "es6",
        "lib": [ "es6", "dom" ],
    },
    "include": [
        "./**/*",
        "./**/*.json",
        "../../../node_modules/self-service-server/lib/main/shared/@types/**/*.d.ts",
    ]
}

When copying these files into the sandbox, the paths are not altered, so that they point to non-existent subdirectories and tsc -b is failing.

As a workaround, we added them like this:

{
    "include": [
        "../../../node_modules/self-service-server/lib/main/shared/@types/**/*.d.ts",
        "../../../../../node_modules/self-service-server/lib/main/shared/@types/**/*.d.ts",
    ]
}

Please alter paths and add additional ../../to the entries. This might also make sense for other directives (typeRoots, excludes, ...).

Stryker config

{
    "$schema": "./node_modules/@stryker-mutator/core/schema/stryker-schema.json",
    "_comment": "Stryker Mutator config",
    "packageManager": "yarn",
    "reporters": [
        "html",
        "clear-text",
        "progress"
    ],
    "mutate": [
        "src/main/**/*.ts",
        "!src/main/**/*Spec.ts"
    ],
    "ignorePatterns": ["lib", "build", "www"],
    "testRunner": "mocha",
    "testRunnerNodeArgs": [
        "--require",
        "esm"
    ],
    "mochaOptions": {
        "extension": [
            "ts",
            "tsx"
        ],
        "spec": [
            "src/**/*Spec.ts"
        ],
        "require": [
            "src/test/ts-hook",
            "ignore-styles",
            "mocha-steps"
        ],
        "package": "./package.json",
        "ui": "bdd",
        "async-only": false,
        "grep": ".*"
    },
    "coverageAnalysis": "perTest",
    "checkers": [
        "typescript"
    ],
    "tsconfigFile": "src/test/tsconfig.json"
}

Test runner config

.mocharc.js

'use strict';
module.exports = {
    reporter: 'mocha-better-spec-reporter',
    file: ['src/test/setupEnvironment.ts'],
    extension: ['.ts'],
    require: [
        'esm',
        'src/test/ts-hook',
        'ignore-styles',
        'mocha-steps'
    ],
    recursive: true,
    timeout: '10s',
    exit: true,
};

Stryker environment

├─ @stryker-mutator/api@5.5.0
├─ @stryker-mutator/core@5.5.0
│  ├─ @stryker-mutator/api@5.5.0
│  ├─ @stryker-mutator/instrumenter@5.5.0
│  ├─ @stryker-mutator/util@5.5.0
├─ @stryker-mutator/instrumenter@5.5.0
│  ├─ @stryker-mutator/api@5.5.0
│  ├─ @stryker-mutator/util@5.5.0
├─ @stryker-mutator/mocha-runner@5.5.0
│  ├─ @stryker-mutator/api@5.5.0
│  ├─ @stryker-mutator/util@5.5.0
├─ @stryker-mutator/typescript-checker@5.5.0
│  ├─ @stryker-mutator/api@5.5.0
│  ├─ @stryker-mutator/util@5.5.0
├─ @stryker-mutator/util@5.5.0
├─ mocha@8.4.0
├─ esm@3.2.25
├─ ts-node@9.1.1

Test runner environment

yarn run mocha --exit 'src/**/*Spec.ts'

Your Environment

software version(s)
node 16.13.0
yarn 1.22.10
Operating System
NixOS unstable
@robaca robaca added the 🐛 Bug Something isn't working label Nov 26, 2021
@nicojs
Copy link
Member

nicojs commented Nov 26, 2021

Thanks for opening this issue. As a workaround, could to try to run with --inPlace?

nicojs added a commit that referenced this issue Dec 2, 2021
Rewrite "include" patterns in tsconfig files that fall outside the sandbox.

For example:

```json
{
  include: ['./**/*', '../../node_modules/self-service-server/lib/main/shared/@types/**/*.d.ts'],
}
```

Becomes:

```json
{
  include: ['./**/*', '../../../../node_modules/self-service-server/lib/main/shared/@types/**/*.d.ts'],
}
```

Same is true for `files` and `exclude`.

Fixes #3281
nicojs added a commit that referenced this issue Dec 2, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Rewrite "include" patterns in tsconfig files that fall outside the sandbox.

For example:

```json
{
  include: ['./**/*', '../../node_modules/self-service-server/lib/main/shared/@types/**/*.d.ts'],
}
```

Becomes:

```json
{
  include: ['./**/*', '../../../../node_modules/self-service-server/lib/main/shared/@types/**/*.d.ts'],
}
```

Same is true for `files` and `exclude`.

Fixes #3281
@nicojs
Copy link
Member

nicojs commented Dec 2, 2021

Fix released in v5.5.1

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

Successfully merging a pull request may close this issue.

2 participants