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

fix(index): don't prepend ./ to the URL on interpolate=require (options.interpolate) #165

Merged
merged 2 commits into from
Jan 17, 2018

Conversation

Sawtaytoes
Copy link
Contributor

@Sawtaytoes Sawtaytoes commented Jan 11, 2018

This fixes bug #150 where the URL passed to require() would have ./ prepended when it shouldn't.

Please check if the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior? (You can also link to an open issue here)
#150

What is the new behavior?
require, when interpolated, will no longer prepend ./ to the request url.

Does this PR introduce a breaking change?

  • Yes
  • No

If this PR contains a breaking change, please describe the following...

  • Impact:
  • Migration path for existing applications:
  • Github Issue(s) this is regarding:

Other information:

This fixes bug #150 where the URL passed to `require()` would have `./` prepended when it shouldn't.
@jsf-clabot
Copy link

jsf-clabot commented Jan 11, 2018

CLA assistant check
All committers have signed the CLA.

@hemanth
Copy link
Contributor

hemanth commented Jan 15, 2018

LGTM

index.js Outdated
} else {
urlToRequest = loaderUtils.urlToRequest(data[match], root);
}

return '" + require(' + JSON.stringify(loaderUtils.urlToRequest(data[match], root)) + ') + "';
Copy link
Member

Choose a reason for hiding this comment

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

- return '" + require(' + JSON.stringify(loaderUtils.urlToRequest(data[match], root)) + ') + "';
+ return '" + require(' + JSON.stringify(urlToRequest) + "';

? Or I'm missing something, but it looks like urlToRequest isn't used atm :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was trying to keep existing functionality as sometimes config.interpolate could be true instead of require. I only wanted to change this for the instance I know it's broken.

Copy link
Member

@michael-ciniawsky michael-ciniawsky Jan 15, 2018

Choose a reason for hiding this comment

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

How is the variable urlToRequest applied ? From looking at the code it seems to always return

'" + require(' + JSON.stringify(loaderUtils.urlToRequest(data[match], root)) + ') + "';

atm ? So your changes don't apply ?

Copy link
Contributor Author

@Sawtaytoes Sawtaytoes Jan 15, 2018

Choose a reason for hiding this comment

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

You're correct; my mistake! I made these changes in my local node_modules directory and didn't copy them over correctly when creating the pull request.

@michael-ciniawsky michael-ciniawsky changed the title Fixed interpolate=require prepending ./ to url fix(index): prepend ./ to the URL on interpolate=require (options.interpolate) Jan 15, 2018
@michael-ciniawsky michael-ciniawsky added this to the 0.5.5 milestone Jan 15, 2018
@michael-ciniawsky michael-ciniawsky changed the title fix(index): prepend ./ to the URL on interpolate=require (options.interpolate) fix(index): don't prepend ./ to the URL on interpolate=require (options.interpolate) Jan 15, 2018
Copy link
Contributor Author

@Sawtaytoes Sawtaytoes left a comment

Choose a reason for hiding this comment

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

Corrected the earlier mistake of forgetting to use urlToRequest.

index.js Outdated
} else {
urlToRequest = loaderUtils.urlToRequest(data[match], root);
}

return '" + require(' + JSON.stringify(loaderUtils.urlToRequest(data[match], root)) + ') + "';
Copy link
Contributor Author

@Sawtaytoes Sawtaytoes Jan 15, 2018

Choose a reason for hiding this comment

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

You're correct; my mistake! I made these changes in my local node_modules directory and didn't copy them over correctly when creating the pull request.

@Sawtaytoes
Copy link
Contributor Author

I put in the required change to make this function properly. Do you know the ETA on when this would work its way into the codebase?

@michael-ciniawsky
Copy link
Member

Released in v0.5.5 🎉

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

Successfully merging this pull request may close these issues.

4 participants