Skip to content

Publishing to NPM while using the tsconfig paths? #25677

@oleersoy

Description

@oleersoy

Hello - Hope it's OK that I ask this question here. I first posted it to SO and have seen similar questions asked without answers. This is the SO question:

https://stackoverflow.com/questions/51353762/compiling-typescript-path-aliases-to-relative-paths-for-npm-publishing

In addition I created a small project with a directory structure like this:

├── package.json
├── src
│   ├── boo.ts
│   └── foo
│       └── foo.ts
├── target
│   ├── boo.d.ts
│   ├── boo.js
│   └── foo
│       ├── foo.d.ts
│       └── foo.js
└── tsconfig.json

I setup the `baseUrl` and `paths` option like this:

"baseUrl": "./",
"paths": {
    "@fireflysemantics/*": [ "src/*" ]
},

In this case `boo` imports `foo` and when compiled the import looks like this:

"use strict";
exports.__esModule = true;
var foo_1 = require("@fireflysemantics/foo/foo");
function boo() {
console.log("The boo is loose");
foo_1.foo();
}
exports.boo = boo;


So as you can see the `require` is still importing from the @fireflysemantics alias defined in the `tsconfig`.  However when published to NPM, node does not necessarily know where that is.  Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Out of ScopeThis idea sits outside of the TypeScript language design constraints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions