Skip to content

Config file detected incorrectly when TS_NODE_PROJECT is defined #112

@khitrenovich

Description

@khitrenovich

Problem

When TS_NODE_PROJECT environment variable is defined, the config path will be detected incorrectly and the plugin will not work.
The configFile configuration parameter will be ignored even if provided.

Example:

Command Resulting Using config file at ... output Correct?
webpack ...client/management/tsconfig.json
TS_NODE_PROJECT=tsconfig.json webpack ...client/management/tsconfig.json/tsconfig.json
TS_NODE_PROJECT=tsconfig.tools.json webpack ...client/management/tsconfig.json/tsconfig.tools.json

Use case

I have two TS config files - main and tooling.

Main:

  "compilerOptions": {
    ...
    "module": "esnext",
    "moduleResolution": "bundler",
    "paths": {
      "@root/*": ["./src/app/*"]
    }
  },

Tooling:

  "extends": "./tsconfig.json",
  "compilerOptions": {
    "module": "commonjs",
    "moduleResolution": "node"
  },

However, invoking webpack via TS_NODE_PROJECT=tsconfig.tools.json webpack breaks tsconfig-paths-webpack-plugin.

Workaround

  • Create a wrapper script that registers tooling TS project and invokes webpack CLI programmatically.
  • Provide explicit main config file to the tsconfig-paths-webpack-plugin via configFile property.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions