joonhocho / tscpaths Goto Github PK
View Code? Open in Web Editor NEWReplace absolute paths to relative paths after typescript compilation
License: MIT License
Replace absolute paths to relative paths after typescript compilation
License: MIT License
Does it work in watch mode?
Hello! I cloned your job and I arranged it. You can visit it at https://github.com/justkey007/tsc-alias.
Currently, just take the typed configuration and without the other options. Excuse me I speak French which I used the machine translation but my message was poorly translated and I noticed too late.
https://github.com/joonhocho/tscpaths/blob/master/src/index.ts#L11
Should be updated with next release.
Not sure why this would be happening. It does it regardless of if I chain the tsc and tscpaths commands or not.
Output:
require("../shared/index.ts");
Expected:
require("../shared/index.js");
Actually, require(PATH_TO_TSCONFIG_JSON)
will break, if tsconfig.json
has comments. I didn't inserted the comments myself, but npx tsc --init
did.
Not really sure how tsc
internally read JSON with comments...
Consider:
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@test/*": ["./test/*"],
"*": ["./src/*"]
},
}
It totally skips over the "*"
setting.
Hi @joonhocho, cc: @jonkwheeler, @adam187,
I’m seeing that there are issues opened since 2018 and pull requests from 2019. Any chance that you have decided to no longer maintain this project anymore?
In that case, it would be good to state it in the README, I use this package in all my libraries and I would like to address some of the issues that it has. I would be also open to being a maintainer of the project or taking it over if you are no longer interested.
Regards
My tsconfig.json
contains an extends
property, which targets a config that is a node_module dependency:
{
"extends": "@org/ts-config",
...
}
however this breaks tscpaths:
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module '<redacted>/@org/ts-config'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.exports.loadConfig (<redacted>/node_modules/tscpaths/cjs/util.js:16:12)
at Object.exports.loadConfig (<redacted>/node_modules/tscpaths/cjs/util.js:28:38)
at Object.<anonymous> (<redacted>/node_modules/tscpaths/cjs/index.js:37:43)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
it seems loadConfig()
in utils
is not able to correctly resolve non-relative/non-absolute extends
clauses.
Is there any change to integrate it with ts-loader or awesome-typescript-loader ?
require("alias/file")
works fine, but if you have an index file under the alias and reference only require("alias")
, it doesn't work. Imports to the root of an alias never gets replaced.
From what I see, this project has been abandoned, if anyone goes through the same problem, you need to replace the line 105 in this file for:
if (modulePath.startsWith(prefix) || modulePath === prefix.replace(/\/$/, '')) {
I don't mind providing the input
and output
directory.
But I think the output
should be directly reference compilerOptions.outDir
found in the tsconfig.json
description.
Seeing replaced paths is good but not when there are 200+ files there should be a way to disable these logs.
I've been running this over some image assets that are aliased and getting back "could not replace". When this line executes with a .ts file, it looks like the path is getting combined with the file name to get the full location. But when it executes with a .png file, only the image file name comes back.
Line 114 in 99622e9
I wonder if something as simple as path + filename
would suffice here, rather than using the resolve function.
https://www.npmjs.com/advisories/1751
node_modules/glob-parent
fast-glob <=2.2.7
Depends on vulnerable versions of glob-parent
node_modules/tscpaths/node_modules/fast-glob
globby 8.0.0 - 9.2.0
Depends on vulnerable versions of fast-glob
node_modules/tscpaths/node_modules/globby
tscpaths *
Depends on vulnerable versions of globby
node_modules/tscpaths
please update the globby package to fix this issue, thanks!
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.