momothepug / tsmodule-alias Goto Github PK
View Code? Open in Web Editor NEWNodejs Typescript path register
License: GNU Lesser General Public License v2.1
Nodejs Typescript path register
License: GNU Lesser General Public License v2.1
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:
it seems like its throwing because it's redirecting to dist of the generated typescript folder.
How can I help resolve this issue?
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.
npx tsx --init
will produce a tsconfig.json with both "//" and "/* */" style comments inside. While tsmodule-alias fails to parse this.
I have the following structure:
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.