Skip to content

Should commonSourceDirectory be undefined when outDir, sourceRoot, mapRoot is not specified? #3327

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
unional opened this issue Jun 1, 2015 · 11 comments
Labels
API Relates to the public API for TypeScript Question An issue which isn't directly actionable in code

Comments

@unional
Copy link
Contributor

unional commented Jun 1, 2015

I'm writing some custom code in my fork and realize it is not populated. If needed, I can create a pull request for it. (should be just 4 lines of change).

@mhegazy
Copy link
Contributor

mhegazy commented Jun 1, 2015

That is the only time it is used. if non of these options are defined, the commonSourceDirectory is not needed. what are you trying to do?

@mhegazy mhegazy added Question An issue which isn't directly actionable in code API Relates to the public API for TypeScript labels Jun 1, 2015
@unional
Copy link
Contributor Author

unional commented Jun 1, 2015

I wrote a umd library that allow user to write code that can be used in browser global, requireJS, and commonJS as-is (i.e. without recompile, see [https://github.com/unional/write-umd]). I use this internally so I create a fork of TypeScript to generate that (see [https://github.com/unional/TypeScript]).

The code will use umdBaseDir specified by the user or the commonSourceDirectory if umdBaseDir is not available.

For example, if I have a file at C:\Users\me\codes\myProject\src\Company\app\common\MyClass.ts and the umdBaseDir is specified as **C:\Users\me\codes\myProject\src**, then the full path of MyClass will be Company.app.common.MyClass.

The commonSourceDirectory would work even better because I specify include or exclude in the tsconfig.json to compile all files under ./src. In this case engineers don't need to specify their local environment path in umdBaseDir thus keeping their tsconfig.json in the ignore changelist.

@mhegazy
Copy link
Contributor

mhegazy commented Jun 1, 2015

looks like this is a change local to your fork then. up to you to decided what when is commonSourceDirectory needs to be evaluated.

@mhegazy mhegazy closed this as completed Jun 1, 2015
@unional
Copy link
Contributor Author

unional commented Jun 1, 2015

Ok. Thanks.

@basarat
Copy link
Contributor

basarat commented Jun 2, 2015

see [https://github.com/unional/write-umd])

@unional I get that this is different ^ but we do have some umd support. See #2605 for details (and https://github.com/Microsoft/TypeScript/blob/378b5ffd1af2249658c8b7a3dc7465d911af93ff/tests/baselines/reference/umdDependencyCommentName2.js)

@unional
Copy link
Contributor Author

unional commented Jun 2, 2015

Yes, I'm aware of the UMD pattern support. The difficulty I have with the UMD pattern is that it doesn't not support browser global properly. e.g.:

You have a module under Company/app/components/compX.js which is Company.app.components.compX

You can require it by require('Company/app/components/compX'); in AMD or CommonJS.
But the code with this require will not work in environment that you loads the script files using script tags because the require method does not exist. You can't create a global require method to fake the code and do resolution either because a lot of 3rd party library doesn't do AMD/CommonJS detection properly (i.e., they just check whether if the require method exists).

Therefore I wrote write-umd to solve that problem (and a much cleaner syntax IMO :P). It will detect which environment it is in and do the right thing.

@unional
Copy link
Contributor Author

unional commented Jun 2, 2015

And you encourage me to update the README. :)

@mhegazy
Copy link
Contributor

mhegazy commented Jun 2, 2015

@unional have you considered ///<amd-module name=".." />?

@unional
Copy link
Contributor Author

unional commented Jun 3, 2015

@mhegazy do you mean if I have a file /Users/me/codes/projectx/src/Company/app/components/compX.ts and in the file I specify ///<amd-module name="../../../"/> then I can use that information to locate the root folder /Users/me/codes/projectx/src?

@mhegazy
Copy link
Contributor

mhegazy commented Jun 3, 2015

Possibly :)

@unional
Copy link
Contributor Author

unional commented Jun 3, 2015

Currently I use sys.getCurrentDirectory() + compilerOptions.umdBaseDir to solve that problem (although I should consider renaming it to umdxRootPath where umdx is the monika I use in --module umdx so it live with the existing umd value).

It would be even better If I can get the path to the config file and do the right adjustments (e.g. /Users/me/codes/projectX> tsc @app/tsconfig.json would get the current directory as /Users/me/codes/projectX/app). :)

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
API Relates to the public API for TypeScript Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

3 participants