title: TypeScript Module Resolution doesn't quite work with Cucumber-js
body: <p>I'm doing a small Proof of Concept for <strong>Cucumber-js</strong> – using TypeScript. So far everything is fine...but I can't find a way to properly configure the <em>module resolution</em> when using <code>tsconfig-paths</code>.</p>
  
  <p>This is <a href="https://github.com/x80486/cucumber-typescript/" rel="nofollow noreferrer">my project</a> structure:</p>
  
  <pre class="lang-sh prettyprint-override"><code>.
  ├── cucumber.js
  ├── features
  │   └── bank-account.feature
  ├── package.json
  ├── package-lock.json
  ├── step-definitions
  │   └── bank-account.steps.ts
  ├── support
  │   └── model
  │       └── bank-account.model.ts
  ├── tsconfig.json
  └── tslint.json
  </code></pre>
  
  <p>I'm using <code>cucumber-tsflow</code>, so the "step definitions" looks like:</p>
  
  <pre class="lang-js prettyprint-override"><code>// import { BankAccount } from "@model/bank-account.model"; // ...trouble!
  import { BankAccount } from "../support/model/bank-account.model";
  
  import { expect } from "chai";
  import { binding, given, then, when } from "cucumber-tsflow";
  
  @binding()
  export class BankAccountSteps {
    ...
  
    @when("{int} is deposited")
    public when(amount: number) {
      this.account.deposit(amount);
    }
  
    ...
  }
  </code></pre>
  
  <p>...but I can't make use of <code>@model/bank-account.model</code>, even though I have it properly configured in <code>tsconfig.json</code> and <code>cucumber.js</code>:</p>
  
  <pre><code># file: tsconfig.json
  {
    "compilerOptions": {
      "baseUrl": ".",
      ...
      "paths": {
        "*": ["./*"],
        "@model/*": ["./support/model/*"]
      },
      ...
      "types": [
        "@types/chai",
        "@types/cucumber",
        "node"
      ]
    },
    "exclude": ["node_modules/"],
    "include": ["./step-definitions/**/*", "./support/**/*"]
  }
  </code></pre>
  
  <pre><code># file: cucumber.js
  const common = [
    "features/**/*.feature",
    "--require-module ts-node/register",
    // "--require-module tsconfig-paths/register",
    "--require step-definitions/**/*.ts",
    "--require support/**/*.ts"
  ].join(" ");
  
  module.exports = {
    default: common,
  };
  
  </code></pre>
  
  <p>As soon as I "activate" <code>tsconfig-paths</code> – read: uncomment <code>"--require-module tsconfig-paths/register"</code> inside <code>cucumber.js</code>, I get this error message:</p>
  
  <pre class="lang-sh prettyprint-override"><code>$ npm run test
  
  &gt; cucumber-js --profile default
  
  TypeError: cucumber_1.Before is not a function
      at _.once (/home/x80486/Workshop/Development/cucumber-basics/node_modules/cucumber-tsflow/src/binding-decorator.ts:78:3)
      at /home/x80486/Workshop/Development/cucumber-basics/node_modules/underscore/underscore.js:957:21
      at /home/x80486/Workshop/Development/cucumber-basics/node_modules/cucumber-tsflow/src/binding-decorator.ts:38:5
      at __decorate (/home/x80486/Workshop/Development/cucumber-basics/step-definitions/bank-account.steps.ts:5:95)
      at Object.&lt;anonymous&gt; (/home/x80486/Workshop/Development/cucumber-basics/step-definitions/bank-account.steps.ts:8:30)
      at Module._compile (internal/modules/cjs/loader.js:776:30)
      at Module.m._compile (/home/x80486/Workshop/Development/cucumber-basics/node_modules/ts-node/src/index.ts:473:23)
      at Module._extensions..js (internal/modules/cjs/loader.js:787:10)
      at Object.require.extensions.(anonymous function) [as .ts] (/home/x80486/Workshop/Development/cucumber-basics/node_modules/ts-node/src/index.ts:476:12)
      at Module.load (internal/modules/cjs/loader.js:653:32)
      at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
      at Function.Module._load (internal/modules/cjs/loader.js:585:3)
      at Module.require (internal/modules/cjs/loader.js:690:17)
      at require (internal/modules/cjs/helpers.js:25:18)
      at supportCodePaths.forEach.codePath (/home/x80486/Workshop/Development/cucumber-basics/node_modules/cucumber/lib/cli/index.js:142:42)
      at Array.forEach (&lt;anonymous&gt;)
  </code></pre>
  
  <p>Anyone versed in TypeScript and/or Cucumber can shed some light on what's going on here?</p>
  
  <hr>
  
  <p><strong>UPDATE</strong></p>
  
  <p>If I delete <code>cucumber.js</code> and just pass all the options in the <code>npm</code> script (<code>"test": "cucumber-js features/**/*.feature --require-module ts-node/register --require-module tsconfig-paths/register --require step-definitions/**/*.ts --require support/**/*.ts"</code>) it works :mind-blowing:</p>
  
  <p>Also, changing <code>baseUrl</code> to something other than <code>"./"</code>, for instance, <code>"./support"</code>, without deleting <code>cucumber.js</code> does the trick.</p>