Skip to content

feat: ensure module paths in source map include full path from current working directory #26

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

Closed

Conversation

bryanforbes
Copy link

This pull request is similar to #9. If the loader is configured with includeModulePaths set to true, the path of the source file will be computed relative to the current working directory if possible. This maintains the default behavior for most users but allows users to opt-into this behavior.

@bryanforbes bryanforbes mentioned this pull request Feb 15, 2017
3 tasks
@joshwiens joshwiens self-assigned this Mar 7, 2017
@joshwiens
Copy link
Member

@bryanforbes - To trigger the CLA assistant now that it's actually turned on, close & open the pull request again ( this one ) and please rebase with current master to pick up the Travis build.

@jsf-clabot
Copy link

jsf-clabot commented Mar 8, 2017

CLA assistant check
All committers have signed the CLA.

@bryanforbes
Copy link
Author

The latest loader-utils has a deprecation warning when using parseQuery(), so I updated the code to use getOptions().

Copy link
Member

@michael-ciniawsky michael-ciniawsky left a comment

Choose a reason for hiding this comment

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

@michael-ciniawsky
Copy link
Member

@bryanforbes A quick note in the docs before merging would be appreciated :)

@michael-ciniawsky
Copy link
Member

@bryanforbes In #9 was implemented without adding an extra option, so my question is would it be possible without an extra options (includeModulePath) or is this definitely breaking things then?

Off topic but could you bump the async dependency on the fly? 🙃 #7

@bryanforbes
Copy link
Author

I was trying to maintain backwards compatibility with the flag so people could opt-into the new behavior (in case there were problems or someone liked all of their source mapped files strewn about). If that's not a concern, I can remove the flag and we won't need getOptions().

Yes, I can bump the async dependency on the fly. Is @latest OK?

@michael-ciniawsky
Copy link
Member

I was trying to maintain backwards compatibility with the flag so people could opt-into the new behavior (in case there were problems or someone liked all of their source mapped files strewn about). If that's not a concern, I can remove the flag and we won't need getOptions().

cc @bebraw @d3viant0ne

Is @latest OK?

Thx 👍 . I think (believe) not :D .If there is the smallest problem coming up, don't bother with (it's not really your problem) 😛

@bebraw
Copy link
Contributor

bebraw commented Mar 8, 2017

I guess ideally there would be no flag. The problem is that if we drop the flag, then it's a breaking change (major version bump).

@bryanforbes
Copy link
Author

@bebraw Isn't this slated for 1.0.0 which would be a major version bump anyway?

@joshwiens
Copy link
Member

joshwiens commented Mar 8, 2017

@bryanforbes - Here's the thing with a major, we are standardizing all of the loaders & plugins which is going to require a bit of coordination so we don't have to release back to back majors.

One answer here is this lands without a flag as a non-backwards compatible feature ( both for the lack of flag & the loader-utils bump ) and is done conjunction with the update to webpack-defaults which enforces a minimum version of NodeJS 4.3 & exports an ES module.

When all of that is in master, it will be published as 1.0.0-beta.0 on the @beta dist-tag

@michael-ciniawsky
Copy link
Member

I agree with @d3viant0ne here, but @bryanforbes please feel free to express your opinion here also, since it would again require changes to your PR, we would appreciate it though if we could tag this for 1.0.0 in a clean way :)

@joshwiens
Copy link
Member

joshwiens commented Mar 8, 2017

That said, this does have benefits to the 0.x.x version as well though that would require the removal of the loader-utils update ( requires NodeJS > 4.3 which is breaking ) and the flag to remain so this is an opt in feature.

Release it as a Minor and remove the flag soon after in the pending Majorwhich now that i think about it is the path which is most beneficial to everyone.

@joshwiens joshwiens requested a review from bebraw March 10, 2017 05:43
if (params.includeModulePaths) {
// Ensure module paths include full path from current working directory
var pwd = process.cwd();
if (context.substring(0, pwd.length) === pwd) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The if bit feels like a helper function. Probably cleaner after extracting it.

Copy link
Author

Choose a reason for hiding this comment

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

I'm not sure what you mean. Would the if be in the helper function? Is extracting ~10 lines of code to another function going to add clarity?

Copy link
Contributor

Choose a reason for hiding this comment

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

if (context.substring(0, pwd.length) === pwd) { felt like a helper based on the code below. Probably better wait on someone else's comment on this.

Copy link
Author

Choose a reason for hiding this comment

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

Oh, I see what you're saying. I didn't extract it out because I don't see it being used anywhere else. IMO, anonymous functions in that case. But I can extract it out if need be.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, anonymous at tops. 👍

Copy link
Author

Choose a reason for hiding this comment

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

Do you mean turn it into a named function and place it at the top of the loader function (after line 20)?

Copy link
Contributor

Choose a reason for hiding this comment

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

That would work. Just extracting is enough for me. 👍

Copy link
Author

Choose a reason for hiding this comment

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

I just looked again. Extracting it to line 20 isn't possible. It's using the map and context arguments from processMap(). It's similar to the callbacks passed to async.map() at line 63.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, let's leave it as is. No need to get stuck here.

Copy link
Author

Choose a reason for hiding this comment

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

👍 Sounds good

@@ -3,7 +3,7 @@ var fs = require("fs");
var should = require("should");
var loader = require("../");

function execLoader(filename, callback) {
function execLoader(filename, callback, includeModulePaths) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not so sure about the flag. It would feel better to have another function (exec???Loader).

@bryanforbes
Copy link
Author

@d3viant0ne I want to be sure I'm reading what you said right:

  1. I back out loader-utils changes and keep flag
  2. You guys release 0.X.X with those changes
  3. I submit a new PR (or you guys update master after the 0.X.X release) to remove the flag and make the module path behavior default
  4. You guys release 1.0.0

@michael-ciniawsky michael-ciniawsky changed the title Ensure module paths in source map include full path from current working directory feat: ensure module paths in source map include full path from current working directory Jun 5, 2017
@michael-ciniawsky
Copy link
Member

Status ? :)

@michael-ciniawsky michael-ciniawsky added this to the 0.3.0 milestone Jun 5, 2017
swernerx added a commit to swernerx/source-map-loader that referenced this pull request Aug 4, 2017
@swernerx
Copy link

swernerx commented Aug 4, 2017

See also #50 which includes this + adds a 'quiet' option to disable emitting of warnings.

@joshwiens
Copy link
Member

@bryanforbes - FYI i'm going to try and get this into a 1.0.0-beta build by the end of the week. Ignore the plan ^^ & leave loaderUtils as is.

@joshwiens joshwiens removed their assignment Aug 17, 2017
@unional
Copy link

unional commented Nov 2, 2017

Can't up vote this enough. This is a major use case and major pain for any package author/consumer who uses TypeScript.
Is the 1.0.0 getting ready soon? 🌷

@joshwiens
Copy link
Member

@bryanforbes - Can you give this a quick rebase when you have a moment please.

@hipstersmoothie
Copy link

I can resolve the package.json conflict if necassary ;) really hankering for this release!

10xjs added a commit to sensu/sensu-go that referenced this pull request May 23, 2018
This module is installed directly from a github URL pending resolution of webpack-contrib/source-map-loader#26.

Signed-off-by: Neal Granger <neal@nealg.com>
@alexander-akait
Copy link
Member

Fixed in the master

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.

9 participants