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

[ts-transform-paths] cannot map to package.json at root folder #21

Closed
opensas opened this issue Dec 2, 2019 · 2 comments
Closed

[ts-transform-paths] cannot map to package.json at root folder #21

opensas opened this issue Dec 2, 2019 · 2 comments

Comments

@opensas
Copy link

opensas commented Dec 2, 2019

I have the following setup in my tsconfig.json

    "baseUrl": "./",
    "paths": {
      "@project/*": ["./*"],
      "*": ["./src/*"],
      "@*": ["./src/*"],
    },
    //"plugins": [
    //  { "transform": "ts-transformer-imports" }
    //],

    "plugins": [
       { "transform": "@zerollup/ts-transform-paths", "exclude": ["*"] }
    ],

And in my start.ts

import { name as appName } from '@project/package.json'

After compiling with ttsc I get this in my start.js

[...]
Object.defineProperty(exports, "__esModule", { value: true });
var package_json_1 = require("@project/package.json");
var app_1 = __importDefault(require("./app"));
[...]

It looks like it cant map the @project/package.json reference and just leaves it like this, without any error or warning...

With ts-transformer-imports (commented in the tsconfig file) and with tsconfig-paths it works ok, and I get package.json mapped like this:

Object.defineProperty(exports, "__esModule", { value: true });
var package_json_1 = require("../package.json");
var app_1 = __importDefault(require("./app"));
var config_1 = __importStar(require("./lib/config/config"));

Also tried with this configuration in tsconfig, same result:

    "baseUrl": "./src",
    "paths": {
      "@project/*": ["./../*"],
      //"@project/package.json": ["./../package.json"],
      "@*": ["./*"],

I'm not sure if the problem is with having a reference to something outside of my baseUrl or with references to .json files

thanks a lot

@zerkalica
Copy link
Owner

try 1.7.8

@opensas
Copy link
Author

opensas commented Dec 3, 2019

I can confirm that with version 1.7.8 everything seems to work ok.

No I can run ts-node with ts-node -C ttypescript src/start.ts and it works too

You've responded with a new version solving the issue in just a couple of hours!!!

FLOSS really rocks, congratulations on the great job you are doing

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

No branches or pull requests

2 participants