question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow regular flags to mix with --build

See original GitHub issue

TypeScript Version: 3.0.0-rc, 3.0.0-dev.20180712

Search Terms:

build mode, --build

Code

I have project with the following tsconfig.json:

{
    "compilerOptions": {
        "module": "commonjs",
        "moduleResolution": "node",
        "target": "es2017",
        "lib": ["es2017"],
        "strict": true,
        "sourceMap": true,
        "noEmitOnError": true,
        "types": ["node"]
    },
    "include": [
        "src/**/*.ts"
    ]
}

and compile it with command:

node_modules/.bin/tsc --build tsconfig.json --outDir out --rootDir /home/kostya/proj/foo

Note, that outDir and rootDir options come from command line arguments, because I want to share output directory for another command (clean).

Expected behavior:

outDir and rootDir options will be took from command line.

Actual behavior:

Compiler ignores this options:

node_modules/.bin/tsc --build tsconfig.json --outDir out --rootDir /home/kostya/proj/foo
message TS6096: File '/home/kostya/proj/foo/--outDir' does not exist.

message TS6096: File '/home/kostya/proj/foo/out' does not exist.

message TS6096: File '/home/kostya/proj/foo/--rootDir' does not exist.

Playground Link:

Related Issues: https://github.com/Microsoft/TypeScript/issues/25600

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:5
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
BTOdellcommented, Jul 21, 2021

To start, only boolean command line flags could be enabled to work with --build mode. And only flags that affect the emitted output files (not so much the type-checking settings).

Here are some initial command line options that could be supported in --build mode:

  • --declarationMap
  • --emitBOM
  • --emitDeclarationOnly
  • --emitDecoratorMetadata
  • --importHelpers
  • --inlineSourceMap
  • --inlineSources
  • --noEmitOnError
  • --removeComments
  • --skipDefaultLibCheck
  • --skipLibCheck
  • --sourceMap
  • --stripInternal

(I haven’t verified whether all of these options currently don’t work in --build mode, but I think they all should)

Supporting options such as --outDir is problematic because relative paths are allowed and they are resolved against the tsconfig in which they are defined. So, it doesn’t make much sense to have a single outDir override for multiple tsconfigs in a project.

2reactions
gh-andrecommented, Apr 6, 2021

I came across of this issue while trying to set up an incremental build in Azure and it seemed like --build was the answer because the docs describe it as “smart incremental builds for TypeScript projects”. However, it turns out that this is just an inaccurate description and the point of --build has nothing to do with incremental builds for a single project.

After failing to set up a build with --build and --outDir I experimented a bit with just using the usual --project and --outDir and it turns out that it it builds incrementally just fine and maintains the build state in tsconfig.tsbuildinfo, without having to use --build. Reading this thread and the docs again, I see that --build’s point isn’t incremental builds, but rather building multiple projects in a way that builds them in the correct order of their dependencies.

I wish TypeScript docs would be more technical and contained fewer things like “Don’t worry about …” and more of what those features actually do and how they interact. Maybe then docs would capture more clearly the intent behind some of those features. This also includes the TypeScript language docs.

Back to --build, being able to generate output in an arbitrary build directory is a requirement of any build pipeline. The --build feature is just not very useful without being able to choose where the output for those multiple projects goes to. Whether it sets some common root for all projects being built or uses some macros, there should be a way to choose the output directory using build pipeline machinery.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to get arguments with flags in Bash - Stack Overflow
This will allow you to use flags so no matter which order you are passing the parameters you will get the proper behavior....
Read more >
Compiler Flags - Docswiki
CMake allows the specification of flags for three different build types: Release For general usage. Can include optimisation options and disable ...
Read more >
How To Use the Flag Package in Go - DigitalOcean
Go lets you craft command-line utilities that accept flags by using the flag package from the standard library. In this tutorial you'll explore ......
Read more >
Common Installation Mistakes to Avoid with House Flag Poles
Most telescoping flagpole companies suggest using regular concrete, rather than ready to mix cement as it dries naturally and ensures the ...
Read more >
Optimize Options (Using the GNU Compiler Collection (GCC))
Turning on optimization flags makes the compiler attempt to improve the performance and/or code size at the expense of compilation time and possibly...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found