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

Allow any alias to be used for external modules #83

Closed
wants to merge 2 commits into from

Conversation

jmreidy
Copy link
Owner

@jmreidy jmreidy commented Aug 15, 2013

Previous to 2.27.0, browserify required external module ids to resolve
to a filepath. That's no longer the case, which means that grunt-browserify
can now make the aliasing / externaling process much more
straightforward. See the updated examples for how to implement.

Previous to 2.27.0, browserify required external module ids to resolve
to a filepath. That's no longer the case, which means that grunt-browserify
can now make the aliasing / externaling process much more
straightforward. See the updated examples for how to implement.
@jmreidy
Copy link
Owner Author

jmreidy commented Aug 15, 2013

Open for review: any comments @shama, @joeybaker, @bclinkinbeard? (Or anybody else for that matter?)

@jmreidy
Copy link
Owner Author

jmreidy commented Aug 15, 2013

For reference, the browserify PR that added this functionality: browserify/browserify#473

@bclinkinbeard
Copy link
Contributor

I only took a cursory glance but looks good to me. Is the alias just coming from the object key inside shim here? https://github.com/jmreidy/grunt-browserify/blob/5aa8f09115e2598e230aa823c9ee90a548909496/examples/complex/Gruntfile.js Might be worth calling out. Nice work!

@jmreidy
Copy link
Owner Author

jmreidy commented Aug 15, 2013

@bclinkinbeard yep that's exactly right. I'll make a note of that in the README.

@joeybaker
Copy link
Contributor

This is sweet! I took a quick look through the task code and it looks good enough to me. Thanks!

@joeybaker joeybaker mentioned this pull request Aug 15, 2013
if (expandedExternals.length > 0) {
expandedExternals.forEach(function (dest) {
var externalResolved = path.resolve(dest)
if (grunt.file.exists(externalResolved)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you'll need a second check here for && grunt.file.isFile(externalResolved)). exists will return true on both directories and files, which can also both be returned from grunt.file.expand.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's how I originally implemented it, but there's currently functionality to make an entire directory external (see external-dir test).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, I missed that. Nifty.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After reading the test, maybe: && (grunt.file.isFile(externalResolved) || grunt.file.isFile(path.join(externalResolved, '/index.js'))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Saw you merged this – awesome! Is the comment above worth a PR, or have a misunderstood again?

var expandedExternals = grunt.file.expand(external);
if (expandedExternals.length > 0) {
expandedExternals.forEach(function (dest) {
var externalResolved = path.resolve(dest)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon (not that they are necessary but just to match your existing code style ;)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh also on L75

@shama
Copy link
Contributor

shama commented Aug 15, 2013

+1 LGTM. Nice work Justin!

@jmreidy
Copy link
Owner Author

jmreidy commented Aug 16, 2013

Merged and published in v1.2.3. Thanks for the QA, folks!

@jmreidy jmreidy closed this Aug 16, 2013
@jmreidy jmreidy deleted the allow_arbitrary_aliases branch August 16, 2013 20:19
@jmreidy jmreidy mentioned this pull request Sep 11, 2013
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.

4 participants