Skip to content

imt-jaime/ts-monorepo-issue-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TS Monorrepo Issue Example

Repository created with the purpose to test a common typescript issue with monorepos.

Repository Structure

workspace (ts-monorepo-issue-example)

  • node_modules
    • module-b (linked)
  • src
    • index.js
    • packages
      • module-b (linked globally)
        • node_modules
          • ts-typelib-example (v2.0.0)
          • module-a
            • node_modules
              • ts-typelib-example (v1.0.0)
            • src
            • package.json
        • src
        • package.json
      • ts-typelib-example
        • node_modules
        • src
        • package.json
  • package.json

Issue Description

When 2 major versions of the same module (which changes a type) are installed in different packages, TypeScript cache does not make distinctions. It will take, the first module found as the only one module in the project ignoring nodejs dependencies resolution standard also explained in TypeScript documentation.

This resolution works when the project is a monolith style application (single repository with only 1 package.json) where every dependency will be installed in only 1 version. Actually transpilers (like webpack), npmjs and nodejs also supports monorepos and is helpful while working with npm link.

Test instructions

  1. Clone repository
  2. npm install (for installing modules in repository)
  3. Link module-b to the project (this step is to simulate we are working with this module in local repository)
  4. Execute TypeScript compiler (npm run typescript)

A fail will appear in src/index.ts in the project. This fail is related to microsoft/TypeScript#29221 in TypeScript official github.

Module repositories

ts-issue-module-a ts-issue-module-b ts-typelib-example

tsconfig configurations

Parent project:

{
  "exclude": ["node_modules"],
  "compilerOptions": {
    "target": "esnext",
    "moduleResolution": "node",
    "skipLibCheck": true,
    "declaration": true,
    "strict": true,
    "isolatedModules": false,
    "esModuleInterop": true,
    "jsx": "preserve",
    "module": "commonjs",
    "preserveSymlinks": true
  }
}

Modules:

{
  "exclude": ["node_modules"],
  "compilerOptions": {
    "target": "esnext",
    "moduleResolution": "node",
    "skipLibCheck": true,
    "declaration": true,
    "strict": true,
    "isolatedModules": false,
    "esModuleInterop": true,
    "jsx": "preserve",
    "module": "commonjs"
  }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published