Comments (13)
Found the problem, pushing fix soon.
from tsc-alias.
@gbenson-ff this is a known issue fixed in 1.6.3
.
This is probably a duplicate issue of #97
Please try upgrade to 1.6.3
and check if the issue still occurs.
from tsc-alias.
Upgrading to 1.6.3
doesn't resolve the issue for me. That's actually the version I was using when I noticed the issue.
from tsc-alias.
Is declarationDir
set to something?
What is the baseUrl
?
Is this on windows, mac or linux?
from tsc-alias.
declarationDir
is set to ./dist
baseUrl
is ./
This is on Linux.
from tsc-alias.
It seems I can't reproduce this bug.
This is the config I tried with the same command:
{
"compilerOptions": {
"target": "ES2017",
"module": "commonjs",
"declaration": true,
"outDir": "./dist",
"declarationDir": "./dist",
"baseUrl": "./",
"paths": {
"~*": ["./src/*"]
}
}
}
@justkey007 can you take a look at this?
from tsc-alias.
I think I've narrowed it down a bit. The tsconfig I'm using in this project extends a tsconfig from an npm package. Here's the two:
tsconfig.json
(local)
{
"extends": "@formfree/tsconfig/base.json"
}
@formfree/tsconfig/base.json
(npm package)
{
"extends": "@tsconfig/recommended/tsconfig.json",
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"baseUrl": "../../../",
"declaration": true,
"declarationMap": true,
"declarationDir": "../../../dist",
"importHelpers": true,
"importsNotUsedAsValues": "error",
"jsx": "preserve",
"lib": ["esnext", "dom", "dom.iterable"],
"module": "esnext",
"moduleResolution": "node",
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"outDir": "dist",
"paths": {
"~*": ["./src/*"]
},
"resolveJsonModule": true,
"sourceMap": true,
"target": "esnext"
},
"include": [
"../../../src/*.ts",
"../../../src/**/*.ts"
],
"exclude": [
"../../**/*",
"../../../dist/**/*"
]
}
If I instead dump the contents of @formfree/tsconfig/base.json
into the local tsconfig.json
and adjust the paths, tsc-alias
works correctly. Using the extended config setup like I have above, it doesn't work.
I was using this exact same setup before with [email protected]
and it worked correctly.
from tsc-alias.
@justkey007 can you take a look at this?
Alright, I'll try to reproduce the error so that I fully understand what it is.
@gbenson-ff can you provide us with a repo reproducing the bug in order to quickly resolve this problem?
from tsc-alias.
@gbenson-ff can you provide us the console output when running with -r debugger.js
?
With the debugger.js
file contents being:
let loggedConfig = true;
exports.default = ({ orig, file, config }) => {
if (loggedConfig) {
console.log(config);
loggedConfig = false;
}
console.log(orig);
console.log(file);
return orig;
};
from tsc-alias.
@justkey007 Sure, I can. It'll take me a minute, but I'll comment here again when I have something up.
@raouldeheer I did what you said, but got no console output.
from tsc-alias.
No output means that it found no import statements.
Can you add: console.log(config);
to index.js line 26 of tsc-alias dist directory?
from tsc-alias.
@raouldeheer Sure, here's the output:
> tsc --emitDeclarationOnly --outDir dist && tsc-alias -r debugger.js
{
configFile: '/home/gabe/Coding/work/v2/frontend/packages/common/tsconfig.json',
baseUrl: '../../../',
outDir: '/home/gabe/Coding/work/v2/frontend/packages/common/node_modules/@formfree/tsconfig/dist',
configDir: '/home/gabe/Coding/work/v2/frontend/packages/common',
outPath: '/home/gabe/Coding/work/v2/frontend/packages/common/node_modules/@formfree/tsconfig/dist',
confDirParentFolderName: 'common',
hasExtraModule: false,
configDirInOutPath: null,
relConfDirPathInOutPath: null,
pathCache: PathCache {
useCache: true,
existsCache: Map(0) {},
absoluteCache: Map(0) {}
},
output: Output { verb: false },
aliasTrie: TrieNode { children: Map(1) { '~' => [TrieNode] }, data: null },
replacers: [
[Function: replaceImportStatement],
[Function: replaceBaseUrlImport],
[Function (anonymous)]
]
}
{
configFile: '/home/gabe/Coding/work/v2/frontend/packages/common/tsconfig.json',
baseUrl: '../../../',
outDir: '../../../dist',
configDir: '/home/gabe/Coding/work/v2/frontend/packages/common',
outPath: '../../../dist',
confDirParentFolderName: 'common',
hasExtraModule: false,
configDirInOutPath: null,
relConfDirPathInOutPath: null,
pathCache: PathCache {
useCache: true,
existsCache: Map(0) {},
absoluteCache: Map(0) {}
},
output: Output { verb: false },
aliasTrie: TrieNode { children: Map(1) { '~' => [TrieNode] }, data: null },
replacers: [
[Function: replaceImportStatement],
[Function: replaceBaseUrlImport],
[Function (anonymous)]
]
}
@justkey007 I've put together a repo to reproduce my scenario: https://github.com/gbenson-ff/tsc-alias-bug
If you clone it, run npm i
then npm run build
then cat dist/index.d.ts
you'll see that my tilde aliases are left as-is.
from tsc-alias.
It has loaded the config correctly. ~
is loaded into the aliastrie.
The problem is probably something with the globPattern and the outPath being relative (../../../dist
)
from tsc-alias.
Related Issues (20)
- support resolving aliases that have a .ts extension HOT 7
- Few files affected on second run
- File undefined not found error when loading tsconfig extends file [Yarn 2] HOT 2
- Is it possible to also replace calls to require() function ?
- Package import replaced with relative path to folder name HOT 2
- Readme example has a bad blob pattern
- Adding `../` before external dependency from node_modules HOT 3
- Add support for native `imports` field in package.json
- Tsc-alias is resolving imports inside literal strings and not only import statements; HOT 3
- tsc-alias does not properly replace aliases in declaration files when using a build with emitDeclarationOnly HOT 1
- tsc-alias incorrectly adds .js extension to a module from node_modules HOT 6
- js files don't get transpiled when allowJS is true
- tsc-alias incorrectly replace a module when a file with same name exists in the current directory HOT 2
- production build module without .js from node_modules (symlink)
- How to live preview with this command?
- tsc-alias has bad baseUrl when project name matches folder in external alias HOT 1
- How to use it with webpack ?
- How to tsc-alias it with mocha? HOT 1
- baseUrl value is not accurately recognized
- Libraries imports are replaced with alias HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tsc-alias.