Giter Site home page Giter Site logo

Comments (13)

raouldeheer avatar raouldeheer commented on May 26, 2024 1

Found the problem, pushing fix soon.

from tsc-alias.

raouldeheer avatar raouldeheer commented on May 26, 2024

@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.

gbenson-ff avatar gbenson-ff commented on May 26, 2024

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.

raouldeheer avatar raouldeheer commented on May 26, 2024

Is declarationDir set to something?
What is the baseUrl?
Is this on windows, mac or linux?

from tsc-alias.

gbenson-ff avatar gbenson-ff commented on May 26, 2024

declarationDir is set to ./dist

baseUrl is ./

This is on Linux.

from tsc-alias.

raouldeheer avatar raouldeheer commented on May 26, 2024

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.

gbenson-ff avatar gbenson-ff commented on May 26, 2024

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 avatar justkey007 commented on May 26, 2024

@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.

raouldeheer avatar raouldeheer commented on May 26, 2024

@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.

gbenson-ff avatar gbenson-ff commented on May 26, 2024

@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.
Screenshot from 2022-03-04 09-02-25

from tsc-alias.

raouldeheer avatar raouldeheer commented on May 26, 2024

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.

gbenson-ff avatar gbenson-ff commented on May 26, 2024

@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.

raouldeheer avatar raouldeheer commented on May 26, 2024

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)

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.