Coder Social home page Coder Social logo

momothepug / tsmodule-alias Goto Github PK

View Code? Open in Web Editor NEW
9.0 9.0 1.0 93 KB

Nodejs Typescript path register

License: GNU Lesser General Public License v2.1

JavaScript 2.82% TypeScript 97.18%
dynamic-aliases nodejs path-resolution tsmodule-alias typescript typescript-library typescript2

tsmodule-alias's People

Contributors

danyelmorales avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

bleafman

tsmodule-alias's Issues

Referring nodemodules package point towards typescript dist instead

I'm using the twilio api, within the index.js of twilio api, it calls var obsolete = require('./base/obsolete');

However when i run tsc with tsmodule-alias, it shows this error

internal/modules/cjs/loader.js:985
throw err;
^

Error: Cannot find module '/Users/Keith/.ideas/inreel/inreel-backend/dist/base/obsolete'
Require stack:

  • /Users/Keith/.ideas/inreel/inreel-backend/node_modules/twilio/lib/index.js
  • /Users/Keith/.ideas/inreel/inreel-backend/dist/Tools/Twilio/index.js
  • /Users/Keith/.ideas/inreel/inreel-backend/dist/features/user/userContainer.js
  • /Users/Keith/.ideas/inreel/inreel-backend/dist/Index.js
  • /Users/Keith/.ideas/inreel/inreel-backend/bin/www.js
    at FileNameResolver.Module._resolveFilename (internal/modules/cjs/loader.js:982:15)
    at NodeModuleResolver.invokeFilenameResolver (/Users/Keith/.ideas/inreel/inreel-backend/node_modules/@momothepug/tsmodule-alias/dist/NodeRegister.js:73:42)
    at FileNameResolver.customFileNameResolver (/Users/Keith/.ideas/inreel/inreel-backend/node_modules/@momothepug/tsmodule-alias/dist/NodeRegister.js:104:33)

it seems like its throwing because it's redirecting to dist of the generated typescript folder.

How can I help resolve this issue?

Option to use outDir instead of baseUrl as prefix

In my tsconifg file I have the following lines:

        "outDir": "dist",
        "baseUrl": "src",

This allows me to keep all my ts code in one folder (src) and the entire project after compiling in another (dist). Which is great to avoid uploading useless files to git. However, I have now run into the problem that your TypescriptGenerator.ts always uses the baseUrl as a prefix (which messes up all my paths).
The easiest fix for this would be a way to allow users to use the outDir as a prefix instead. A simple boolean during the setup would be enough.

Replace alias to diferent folder

I have the following structure:

  • mock
    • auth
      • login.ts
    • utils
      • utils.ts

In my file "login. ts " I use the "import {utils} from ' @mock/utils/utils ' " But I want it to point to ' mock-dist/utils/utils ' and not ' mock/utils/Utils ' because tellin' using Dyson to simulate a server

tsconfig.json
{ "compileOnSave": false, "compilerOptions": { "outDir": "./dist/out-tsc", "sourceMap": true, "declaration": false, "moduleResolution": "node", "emitDecoratorMetadata": true, "experimentalDecorators": true, "target": "es5", "typeRoots": [ "node_modules/@types" ], "baseUrl": ".", "paths": { "@service/*": ["src/app/shared/service/*"], "@directive/*": ["src/app/shared/directive/*"], "@component/*": ["src/app/shared/component/*"], "@entity/*": ["src/app/entity/*"], "@enum/*": ["src/app/enum/*"], "@environment/*": ["src/environments/*"], "@shared/*": ["src/app/shared/*"], "@guest/*": ["src/app/guest/*"], "@dashboard/*": ["src/app/dashboard/*"], "@e2e/*": ["e2e/*"], "@factory/*": ["factory/*"], "@mock/*": ["mock/*"] }, "lib": [ "es2017", "dom" ] } }

dyson.js
`
const DYSON = require('dyson')
const PATH = require('path')
const TSModuleAlias = require("@momothepug/tsmodule-alias")
const tsconfigToReadFromRoot = "."
const aliasRegister = TSModuleAlias.play(tsconfigToReadFromRoot)

DYSON.bootstrap({
configDir: PATH.join(__dirname, 'mock-dist'),
port: 3333
})

console.log('DYSON STARTED PORT 3333')
`

Dyson: dyson

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.