Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaks with a TSConfig that "extends" from an external config file #174

Closed
alexlafroscia opened this issue Oct 31, 2024 · 3 comments · Fixed by #175
Closed

Breaks with a TSConfig that "extends" from an external config file #174

alexlafroscia opened this issue Oct 31, 2024 · 3 comments · Fixed by #175

Comments

@alexlafroscia
Copy link

alexlafroscia commented Oct 31, 2024

I tried running this tool on a package of mine that has a tsconfig.json that extends from a shared, external config file

// Config file at `/Users/me/Code/project/tsconfig.json`
{
  "extends": "@company/configs/tsconfig.json"
}

The way that the extends field is handled assumes that you're extending from a local file that can be resolved relative to the one being parsed

const parent = resolveTsConfig(resolve(dirname(file), data.extends))

This is resulting in an exception being raised when trying to run the tool, as it tries and fails to append the external config file's identifier to the directory of the project's config file; with the example config given above at the specified path, the resulting exception would look like

Error: ENOENT: no such file or directory, open '/Users/me/Code/project/@company/configs/tsconfig.json'
@antongolub
Copy link
Owner

antongolub commented Oct 31, 2024

@alexlafroscia,

Oh, I forgot to land @topoconfig/extends here. It's ironic. Thanks for highlighting the issue. v3.1.1 is on the way.

@MirKml
Copy link

MirKml commented Nov 1, 2024

hello @antongolub
this fix in 3.1.1 now produces this fatal error for me

SyntaxError: Expected double-quoted property name in JSON at position 111
    at JSON.parse (<anonymous>)
    at parse (node_modules/@topoconfig/extends/target/esm/index.mjs:52:36)
    at node_modules/@topoconfig/extends/target/esm/index.mjs:96:40
    at pipe (node_modules/@topoconfig/extends/target/esm/index.mjs:23:68)
    at processResource (file:node_modules/@topoconfig/extends/target/esm/index.mjs:91:34)
    at loadResource (node_modules/@topoconfig/extends/target/esm/index.mjs:82:19)
    at populateSync (node_modules/@topoconfig/extends/target/esm/index.mjs:224:19)
    at resolveTsConfig (node_modules/tsc-esm-fix/target/esm/util.mjs:12:42)
    at node_modules/tsc-esm-fix/target/esm/finder.mjs:15:26
    at Array.reduce (<anonymous>)

previous 3.1.0 is without any fatal error

my tsconfig.json

 {
  "compilerOptions": {
    "sourceMap": false,
    "target": "es2022",
    // we want standard classes, see #50947
    "useDefineForClassFields": true,
    "jsx": "react-jsx",
    "module": "ESNext",
    "moduleResolution": "bundler",
    "emitDecoratorMetadata": false,
    "experimentalDecorators": false,
    "declaration": true,
    "resolveJsonModule": true,
    "allowSyntheticDefaultImports": true,
    // transpiles default module imports for babel friendly javascript code
    // necessary for moment.js
    "esModuleInterop": true,
    // it skips checks for bugs in node_modules type declarations
    // discovered in mobx types: https://github.com/mobxjs/mobx/issues/3903
    "skipLibCheck": true,
    "lib": ["es2022", "dom"],
    // don't global imports any types, use always imports in source codes
    "types": []
  }
}

@antongolub
Copy link
Owner

antongolub commented Nov 1, 2024

@MirKml

Mea culpa. Missing json5 parser. Fixed in v3.1.2

antongolub added a commit that referenced this issue Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants