Giter VIP home page Giter VIP logo

Comments (1)

leosvelperez avatar leosvelperez commented on September 27, 2024

Thanks for reporting this!

This is the expected behavior for TypeScript with your setup. The my-app project depends on the source code of products and when you run tsc -p apps/my-app/tsconfig.app.json, the TS compiler creates a ts.Program for that configuration file. It doesn't use any other configuration file unless is extended or referenced. In this case, it extends the tsconfig.base.json and it doesn't reference any other configuration file. Therefore, every file included in the ts.Program will be processed with the apps/my-app/tsconfig.app.json configuration (plus the merged config from the extended tsconfig.base.json). The library source code is part of the ts.Program because:

  • the ts.Program rootDir is the root of the workspace (specified in tsconfig.base.json)
  • it's imported from the application using the path mapping @nx-test/products which is configured to resolve libs/products/src/index.ts (a file inside the rootDir)

So, that's why tsc is processing libs/products/src/lib/products.tsx when running for the apps/my-app/tsconfig.app.json project. Please note that, as mentioned, this is expected TypeScript behavior based on the configuration you shared in the reproduction.

TypeScript has a way to effectively split source code into multiple "projects", which is using project references and tsc -b. By configuring your whole TypeScript setup like a solution where each tsconfig.json file is considered and independent project, tsc can build them independently. An issue with it is that tsc -b is a "build"-only command. You'll always need to at least emit the declaration files.

from nx.

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.