Skip to content

rootDirs does not combine folder contents #9875

Closed

Description

@brantw

When following the example of building a virtual directory using 'rootDirs' in my tsconfig.json file described here I expect the contents /src/views and /generated/templates/views to be combined into a single directory at build. The doc states:

A build step will copy the files in /src/views and /generated/templates/views to the same directory in the output. At run-time, a view can expect its template to exist next to it, and thus should import it using a relative name as "./template".

What actually happens is both folders are copied to the output directory at build, but folder structure is preserved, causing references from one file to the other to be broken.

I have built an example repo that demonstrates this, just run tsc in the root of the checkout to generate the output directory:
https://github.com/brantw/ts-virtual-dir

TypeScript Version: nightly (2.1.0-dev.20160721)

Expected behavior: The contents of the generated\templates\views and src\views folders are combined into the dist folder.

Actual behavior: Both the generated\templates\views and src\views folders are copied to dist, but folder structure is preserved. The two files do not exist next to each other and references from one file to the other are broken.

Activity

  1. brantw commented on Jul 21, 2016

    @brantw
    Author
  2. mhegazy commented on Jul 21, 2016

    @mhegazy
    Contributor

    yes :)

  3. mhegazy commented on Jul 21, 2016

    @mhegazy
    Contributor

    reading ...

  4. mhegazy commented on Jul 21, 2016

    @mhegazy
    Contributor

    well.. as noted in the documentation

    • A build step will copy the files* in /src/views and /generated/templates/views to the same directory in the output. At run-time, a view can expect its template to exist next to it, and thus should import it using a relative name as "./template".

    There is an assumption about this being done at build time.

    The whole module resolution strategy for the compiler is it does not really change where modules are, it just tells the compiler where to find them at design time. Moving files is the responsibility of the build system.

  5. brantw commented on Jul 21, 2016

    @brantw
    Author

    I guess my coworker and I misread "A build step will copy the files in /src/views and /generated/templates/views to the same directory in the output." to mean that the typescript complier would automatically handle the merge of the specified folders, that is why I was looking for a combined output in the root of the output folder. Rereading it after your comments I see that it implies that the developer has added a build step to handle the folder merge. Thanks for clearing that up!

  6. 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

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions