Skip to content
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

Is it possible to specify the AMD module (project) name during compilation? #4027

Closed
sccolbert opened this issue Jul 26, 2015 · 6 comments
Closed
Labels
Fixed A PR has been merged for this issue In Discussion Not yet reached consensus Suggestion An idea for TypeScript

Comments

@sccolbert
Copy link

I have a large library separated into many sub directories and modules which use ES6 module syntax. They are arranged on disk something like this:

src
  |- core
  |    foo.ts
  |    bar.ts
  | - ui
  |     baz.ts
  |     ham.ts

Instead of generating anonymous AMD modules and declaration files, I'd like to be able to specify a root path name and have the output explicitly define the module names, so that the files can be easily concatenated and minified:

foo.js

define('myproject/core/foo', [...], function() { ... } );

foo.d.ts

declare module 'myproject/core/foo' { ... }

Is there a way to do this with the current compiler flags or tsconfig?

@tinganho
Copy link
Contributor

In addition to setting baseurl, I also think something like requirejs route mapping would also be appropriate for TS.

@mhegazy
Copy link
Contributor

mhegazy commented Jul 26, 2015

The current way is to use amd-module tag (more info].

Filling in the names should be simple assuming you have a --rootDir specifided. the question is how you would tell the compiler to do that? new flag? or always do it if you have rootDir?

@mhegazy mhegazy added Suggestion An idea for TypeScript Needs Proposal This issue needs a plan that clarifies the finer details of how it could be implemented. labels Jul 26, 2015
@sccolbert
Copy link
Author

I think a new flag would be reasonable. It would be nice not to have to use an amd-module tag in each module when the names just reflect the input hierarchy. Maybe something like --amdRoot which is used as the root of all module names, with the balance of the name computed from the input directory structure.

@mhegazy mhegazy added In Discussion Not yet reached consensus and removed Needs Proposal This issue needs a plan that clarifies the finer details of how it could be implemented. labels Jul 26, 2015
@mhegazy
Copy link
Contributor

mhegazy commented Jul 26, 2015

is this for both JS and .d.ts? how about enabling --out with --module to generate a single file for all modules with multiple define calls? would that solve the problem?

@sccolbert
Copy link
Author

That would be fantastic. The ultimate goal is to concat the entire library (both JS and d.ts) into a single file(s) which can be distributed and easily consumed by external users via:

import { Foo } from 'myproject/core/foo';
import { Baz } from 'myproject/ui/baz';

Having the compiler generate the module names would at least make it possible to concat with external tools, but having it handle the total sequence would be awesome!

@mhegazy
Copy link
Contributor

mhegazy commented Feb 22, 2016

this should be fixed then by #5090

@mhegazy mhegazy closed this as completed Feb 22, 2016
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Feb 22, 2016
@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
Fixed A PR has been merged for this issue In Discussion Not yet reached consensus Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants