Skip to content

Using baseUrl and paths on node #9259

Description

@unional

I notice the feature is for requirejs and systemjs. And as this comment said, the emitted js code is unchanged by the configuration:
#5039 (comment)

So the primary usage is to resolve packages in various locations (e.g. jspm_packages) for transpilation.

I have the following interesting use case. It worked for me so far as I was using jspm, i.e. the actual module loading happens on the browser. However it fails when I try to do the same using ts-node (fail because it runs on node and the reason above).

Is there a way to support this?

Here is the example:

// tsconfig.json
{
  "compileOptions": {
    "baseUrl": ".",
    "paths": {
      "my-package": [ "src/" ]  // i.e. mapping the package name to the source folder
    }
  }
}

// test/sometest.ts
import abc from 'my-package';
...

i.e., using paths so tests can reference the source as if it is a regular module.
🌷

Reference issue on ts-node: TypeStrong/ts-node#138

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    ExternalRelates to another program, environment, or user action which we cannot control.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions