Skip to content

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

Closed

Description

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?

Activity

  1. tinganho commented on Jul 26, 2015

    @tinganho
    Contributor

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

  2. mhegazy commented on Jul 26, 2015

    @mhegazy
    Contributor

    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?

  3. added
    SuggestionAn idea for TypeScript
    Needs ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.
    on Jul 26, 2015
  4. sccolbert commented on Jul 26, 2015

    @sccolbert
    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.

  5. added and removed
    Needs ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.
    on Jul 26, 2015
  6. mhegazy commented on Jul 26, 2015

    @mhegazy
    Contributor

    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?

  7. sccolbert commented on Jul 26, 2015

    @sccolbert
    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!

  8. mhegazy commented on Feb 22, 2016

    @mhegazy
    Contributor

    this should be fixed then by #5090

  9. locked and limited conversation to collaborators on Jun 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixedA PR has been merged for this issueIn DiscussionNot yet reached consensusSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions