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

feat: Adds a resolved path for output #80

Merged
merged 5 commits into from
Mar 6, 2017

Conversation

pksjce
Copy link

@pksjce pksjce commented Mar 2, 2017

What kind of change does this PR introduce?
This tries to address #73

Did you add tests for your changes?
Yep

If relevant, did you update the documentation?
NA

Summary
To summarise, it tries to implement what was promised in #73

@pksjce pksjce requested a review from okonet March 2, 2017 19:04
Copy link
Contributor

@okonet okonet left a comment

Choose a reason for hiding this comment

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

LGTM in general. See my comments.

describe('getRequire', () => {
it('should create a require statement', () => {
const require = utils.getRequire(j, 'filesys', 'fs');
expect(require).toMatchSnapshot();
Copy link
Contributor

Choose a reason for hiding this comment

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

This should probably create snapshot for the source code. Right now it's for AST.

expect(require.toSource()).toMatchSnapshot()?

Copy link
Author

Choose a reason for hiding this comment

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

Fragments dont actually have .toSource() on them. :( Will try to figure out if this is possible some other way. I think I should be able to convert it to a node somehow.

Copy link
Author

Choose a reason for hiding this comment

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

Had to wrap it in a j()

const path = require('path');
module.exports = {
output: {
path: path.join(__dirname, 'dist')
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add a test where path is imported as a variable with a different name?

const p = require('path') should also work I guess.

Copy link
Author

Choose a reason for hiding this comment

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

Oh yeah, what is path is required in the file but output doesnnt use it? Need to add some more checks.

Copy link
Author

Choose a reason for hiding this comment

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

Added this.

Copy link
Contributor

@okonet okonet left a comment

Choose a reason for hiding this comment

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

Almost there! Awesome work @pksjce 👏

}, false));
if (pathDecalaration) {
isPathPresent = true;
pathDecalaration.forEach(p => {pathVarName = utils.safeTraverse(p, ['value', 'id', 'name']);});
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's put the block code on a new line please. This is hard to read now.

isPathPresent = true;
pathDecalaration.forEach(p => {pathVarName = utils.safeTraverse(p, ['value', 'id', 'name']);});
}
console.log(pathVarName);
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's remove console.log calls please.

pathDecalaration.forEach(p => {pathVarName = utils.safeTraverse(p, ['value', 'id', 'name']);});
}
console.log(pathVarName);
literalOutputPath.find(j.Literal)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the .find() be also a new line?

@pksjce
Copy link
Author

pksjce commented Mar 6, 2017

Hey @okonet - Thanks for the detailed review. I've taken care of the changes.

Copy link
Contributor

@okonet okonet left a comment

Choose a reason for hiding this comment

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

👍

@okonet
Copy link
Contributor

okonet commented Mar 6, 2017

Feel free to squash & merge with the commitizen-compatible commit message!

@pksjce pksjce merged commit 37a594d into webpack:master Mar 6, 2017
@pksjce pksjce deleted the feat/outputpath branch March 6, 2017 09:58
evenstensberg pushed a commit that referenced this pull request Mar 15, 2017
* feat: Adds a resolved path for output

* fix

* fix: Add review fix

* fix: test for source not ast

* fix: review comments
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