Skip to content

File enumeration order in directory-scanning mode should be deterministic #8776

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

Closed
RyanCavanaugh opened this issue May 24, 2016 · 4 comments
Closed
Labels
Infrastructure Issue relates to TypeScript team infrastructure

Comments

@RyanCavanaugh
Copy link
Member

Repro: Set up a.ts, b.ts, each with some statements, and a tsconfig.json in a folder using outFile then compile.

Result: Depending on which order the OS returns the files (which could change per machine), you might get one a.ts's contents before b.ts, or after

We should .sort() https://github.com/Microsoft/TypeScript/blob/adbf8fdee0c9f6ba46d106c4ca972e438511cbcb/src/compiler/commandLineParser.ts#L751 here so that TS builds are deterministic

@basarat
Copy link
Contributor

basarat commented May 24, 2016

Not blindly perhaps. tsconfig.json files order is preserved (#2472) and if not using tsconfig.json then tsc _references.ts order is preserved 🌹

@RyanCavanaugh
Copy link
Member Author

Yep, this should only be when no other ordering data is present

@mhegazy mhegazy added the Infrastructure Issue relates to TypeScript team infrastructure label May 25, 2016
@mhegazy mhegazy removed the Bug A bug in TypeScript label Jun 7, 2016
@rotemdan
Copy link

rotemdan commented Sep 29, 2016

I recently started using the glob based build system through the include property in tsconfig.json. I'm surprised that the globs are not evaluated in written order (after all, it is an ordered list), and subsequently the output file is not concatenated at the order they are stated as that is necessary for my project's build process.

I had to resort to a rather 'ugly' workaround where I number the directories through a prefix to force a particular order:

"compilerOptions": {
  ...
  "outFile": "MyApp.js",
  ...
},

"include": [
  "01_Extensions/**/*.js",
  "01_Extensions/**/*.ts",
  "02_Dependencies/**/*.js",
  "02_Dependencies/**/*.ts",
  "03_Library/**/*.ts",
  "04_Program/**/*.ts",
  ...
]

It seems to work, at least, but doesn't look very professional or like a permanent solution. It would be great if the globs would also provide ordering for the build process and resulting concatenated file. Thanks!

@RyanCavanaugh
Copy link
Member Author

Anyone still using outFile at this point has almost certainly figured this out; Won't Fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Infrastructure Issue relates to TypeScript team infrastructure
Projects
None yet
Development

No branches or pull requests

4 participants