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

Add aliases option to allow named paths #90

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

henrahmagix
Copy link

@henrahmagix henrahmagix commented Jan 10, 2019

Hi,

I wrote this option for my uses, maybe other users would like it too? =)

It allows users with many identical require paths across their files to declare the path once and reference with a name, e.g.

//= require vendor/jquery/jquery.js

becomes

//= require jquery

with options

include({
  aliases: {
    jquery: __dirname + '/vendor/jquery/jquery.js'
  }
});

I've also updated the error message to include the filepath of the include/require, and the top-level filepath at the beginning of the recursion, to aid in debugging when multiple top-level files all include/require the same file, e.g.

Error: No files found matching module "jquery" /Users/me/project/js/vendor/jquery/jquery.js (source: /Users/me/project/js/deep/file_deep.js, starting from /Users/me/project/js/file.js)

for a project structured like so:

project/js
├── vendor
│   └── jquery
│   │   └── jquery.js
├── file.js
└── deep
    └── file_deep.js

Also mark aliases as such in the error.
Otherwise it installs debug@4 which uses ES6 features unsupported in node v0.10
Saves on File IO time spent searching for globs that are aliases.
@KenEucker
Copy link
Collaborator

This is super useful, I think, and would be a great enhancement to this plugin. Let's get this in there after the dependency updates and hopefully we don't see too many collisions with other code that is also coming in.

This PR will need tests written for the use cases this feature presents. If you could provide those tests in your branch, @henrahmagix, that would be super awesome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants