Giter Site home page Giter Site logo

Comments (3)

kyle-belle avatar kyle-belle commented on August 25, 2024

I get the same issue. In my case it happen when i try to import dayjs

relavant tsconfig.json

"outDir": "./build",
      "paths": {
        "@app/db": ["../db"],
        "@app/db/*": ["../db/*"],
        "@app/redis": ["../redis"],
        "@app/redis/*": ["../redis/*"],
        "@app/emitter": ["../emitter"],
        "@app/emitter/*": ["../emitter/*"],
        "@app/dayjs": ["../dayjs"],
        "@app/dayjs/*": ["../dayjs/*"],
        "@app/utils": ["../utils"],
        "@app/utils/*": ["../utils"],
        "@app/values": ["../values"],
        "@app/values/*": ["../values/*"]
      },

tsc input:

import dayjs from "dayjs";

tsc output/tsc-alias input:

const dayjs_1 = __importDefault(require("dayjs"));

tsc-alias output:

const dayjs_1 = __importDefault(require("../dayjs"));

whats strange is there are other dayjs imports that weren't touched

const dayjs_1 = __importDefault(require("../dayjs"));
const advancedFormat_1 = __importDefault(require("dayjs/plugin/advancedFormat"));
const arraySupport_1 = __importDefault(require("dayjs/plugin/arraySupport"));
const isLeapYear_1 = __importDefault(require("dayjs/plugin/isLeapYear"));

from tsc-alias.

kyle-belle avatar kyle-belle commented on August 25, 2024

its really unfortunate because this is the closest i got to having my project transpiled and running with just node. literally if i just remove the ../ from this line manually it works. The other alternative have even more issues. typescript-transform-paths doesn't correctly replace relative paths for me.

this package correctly replaces

require("@app/redis")

with

require("../redis")

it treated outDir as the new base/root which is what i actually want

typescript-transform-paths does this (still tries to pull original ts file from outside outDir):

require("../../../redis");

from tsc-alias.

fdendorfer avatar fdendorfer commented on August 25, 2024

This solved it for me: #185, but i'm using ES imports not CommonJS

from tsc-alias.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.