Skip to content

feat: Adds a resolved path for output#80

Merged
pksjce merged 5 commits intowebpack:masterfrom
kalcifer:feat/outputpath
Mar 6, 2017
Merged

feat: Adds a resolved path for output#80
pksjce merged 5 commits intowebpack:masterfrom
kalcifer:feat/outputpath

Conversation

@pksjce
Copy link
Copy Markdown

@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
Copy Markdown
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.

Comment thread lib/transformations/utils.test.js Outdated
describe('getRequire', () => {
it('should create a require statement', () => {
const require = utils.getRequire(j, 'filesys', 'fs');
expect(require).toMatchSnapshot();
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Author

pksjce commented Mar 6, 2017

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

Copy link
Copy Markdown
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
Copy Markdown
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.

2 participants