theseanl / tscc

A collection of tools to seamlessly bundle, minify Typescript with Closure Compiler
MIT License
161 stars 11 forks source link

Paths ignored in tsconfig #799

Closed adam-rocska closed 11 months ago

adam-rocska commented 1 year ago

Given the following tsconfig.json:

{
  "extends"        : "./node_modules/gts/tsconfig-google.json",
  "compilerOptions": {
    "rootDir": ".",
    "outDir" : "build",
    "paths"  : {
      "#lib/*": ["./lib/*"],
      "#bin/*": ["./bin/*"]
    }
  },
  "include"        : [
    "bin/**/*.ts",
    "lib/**/*.ts",
    "test/**/*.ts"
  ]
}

Apparently my paths are being ignored.

I get TSCC: TypeError: Cannot read properties of undefined (reading 'resolvedModules') errors.

I do imports like so: import { AngleValue } from "#lib/color/AngleValue";

Any ideas maybe?

adam-rocska commented 1 year ago

Ok, I further debugged your library and it looks like what it actually has issues with are node native imports, like:

import * as assert from "assert";
import { parseArgs } from "util";
adam-rocska commented 1 year ago

Further down the rabbit hole, I found this: https://github.com/theseanl/tscc/issues/439#issuecomment-753440455

it does get me through the initial issue, but now another surprise:

                         ClosureCompiler: lib/color/Degree.js.tsickle:6:0: ERROR - [JSC_UNDEFINED_VARIABLE] variable goog is undeclared
  6| goog.module('lib.color.Degree$_ts');
     ^^^^
adam-rocska commented 1 year ago

Ok, I just give up as this makes zero sense.

I npm insalled the same package json and package lock json, same state. Just to remove my console logs from this utility's scripts, and I'm back where I started.

Here's the full log if it helps anyone else, I'll let this go at this point & go back to the old school shitty typescript runtime things.

/Users/rocskaadam/.nvm/versions/node/v18.12.1/bin/npm run compile:bin

> @21GramConsulting/design-system@0.0.0 compile:bin
> rm -rf build/bin && tscc

TSCC: --outDir option is set, but it is no-op for tscc.Use prefix option in spec file to control output directory.
TSCC: --rootDir is set, but it is no-op for tscc. It will internally set to /.
TSCC: tsickle uses a custom tslib optimized for closure compiler. importHelpers flag is set.
TSCC: The compilation has terminated with an unexpected error.
TSCC: TypeError: Cannot read properties of undefined (reading 'resolvedModules')
    at TypescriptDependencyGraph.walk (/Users/rocskaadam/src/21gram.consulting/src/design-system/node_modules/@tscc/tscc/dist/graph/TypescriptDependencyGraph.js:91:12)
    at TypescriptDependencyGraph.walkModeAwareResolvedFileCache (/Users/rocskaadam/src/21gram.consulting/src/design-system/node_modules/@tscc/tscc/dist/graph/TypescriptDependencyGraph.js:54:12)
    at /Users/rocskaadam/src/21gram.consulting/src/design-system/node_modules/typescript/lib/typescript.js:42889:28
    at Map.forEach (<anonymous>)
    at Object.forEach (/Users/rocskaadam/src/21gram.consulting/src/design-system/node_modules/typescript/lib/typescript.js:42887:35)
    at TypescriptDependencyGraph.walk (/Users/rocskaadam/src/21gram.consulting/src/design-system/node_modules/@tscc/tscc/dist/graph/TypescriptDependencyGraph.js:92:26)
    at TypescriptDependencyGraph.addRootFile (/Users/rocskaadam/src/21gram.consulting/src/design-system/node_modules/@tscc/tscc/dist/graph/TypescriptDependencyGraph.js:119:10)
    at /Users/rocskaadam/src/21gram.consulting/src/design-system/node_modules/@tscc/tscc/dist/tscc.js:44:72
    at Array.forEach (<anonymous>)
    at tscc (/Users/rocskaadam/src/21gram.consulting/src/design-system/node_modules/@tscc/tscc/dist/tscc.js:44:38)

Process finished with exit code 1