Skip to content

removeCombined and shared dependencies #958

Open

Description

@platinumazure

I'm in a codebase where we have modules that are composed both of self-contained dependencies and shared helpers. We'd love to use removeCombined but unfortunately some files need to stick around for future module combinations.

Example directory structure:

+ helpers
| |
| -- someHelper
+ src
  |
  + module1
  | |
  | -- mainModuleFile1
  | -- selfContainedDependency1
  + module2
    |
    -- mainModuleFile2
    -- selfContainedDependency2

In this example, src/mainModuleFile1 and src/mainModuleFile2 are the modules that should be generated. Each one requires the "selfContainedDependency" file in its folder plus helpers/someHelper.

A few possible ways around this:

  • Allow removeCombined to be a predicate function (returning true/false, where true implies file can be safely removed as if removeCombined=true had been set)
    • If r.js supported a predicate removeCombined function, we could remove only the "selfContainedDependency" files and leave the helpers/someHelper file.
  • Add an option to avoid removing files that are outside of the directory the main module file is in (I'm not a fan of this due to coupling module names with filesystem which might not work for plugins)

I'm happy to work on a pull request if you are willing to accept either of the options above or have any other suggestions.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions