#Cannot enforce package boundaries in IDEs

4 messages · Page 1 of 1 (latest)

frigid flower
#

I'm having real difficulty enforcing package seperation in a pnpm workspace. IDEs keep trying to auto import modules via relative paths outside of the package. This is despite all of the tsconfigs having well defined include and exclude and all being "composite": true

each package in the workspace has a tsconfig that effectively looks like this:

{
  "$schema": "https://json.schemastore.org/tsconfig.json",
  "extends": "../../tsconfig.base.json",
  "include": ["src", "test"],
  "exclude": ["**/node_modules", "**/.*/"]
}

they all inherit from a base config that looks like this:

{
  "$schema": "https://json.schemastore.org/tsconfig.json",
  "compilerOptions": {
    /* Language features: */
    "target": "ES2024",
    "lib": ["ES2024", "ESNext.Collection", "ESNext.Iterator"]
    /* Filetypes: */
    "allowJs": true,
    "resolveJsonModule": true,
    /* Modules: */
    "allowImportingTsExtensions": true,
    "esModuleInterop": true,
    "isolatedModules": true,
    "module": "nodenext",
    "moduleDetection": "force",
    "rewriteRelativeImportExtensions": true,
    "verbatimModuleSyntax": true,
    "erasableSyntaxOnly": true,
    "composite": true,
    /* For speed: */
    "skipLibCheck": true,
    /* Strictness: */
    "strict": true,
    "noUncheckedIndexedAccess": true,
    "noImplicitOverride": true
  },
  "include": [],
  "files": []
}
#

however, IDEs seem to ignore this and do auto imports like this:

#

but if I actually run tsc I get compiler errors as I might expect:

#

but within IDEs like vscode there is no visual feedback that this is a problem and the editors still try to pull modules outside of their scope via relative paths