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: Allow loading nested objects onto existing libraries #45

Merged

Conversation

TiraO
Copy link
Contributor

@TiraO TiraO commented Mar 28, 2017

e.g. loading a jquery plugin jquery.event.drag should not set event.drag to empty object.

@jsf-clabot
Copy link

jsf-clabot commented Mar 28, 2017

CLA assistant check
All committers have signed the CLA.

Copy link

@bebraw bebraw left a comment

Choose a reason for hiding this comment

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

Looks ok. You need to sign the CLA, though.

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.

@TiraO 👍 Thx

test/test.js Outdated
@@ -20,11 +20,11 @@ describe("loader", function() {
}, "").should.be.eql(HEADER +
// First import
"var abc = (abc || {});\n" +
"abc.def = {};\n" +
"abc.def = abc.def || {};\n" +
Copy link
Member

Choose a reason for hiding this comment

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

Maybe put this in a additional test instead of changing the existing one, if this makes no difference and covers the current purpose of the test, feel free to ignore me here :)

@joshwiens joshwiens changed the title Allow loading nested objects onto existing libraries feat: Allow loading nested objects onto existing libraries Mar 29, 2017
test/test.js Outdated
@@ -9,7 +9,7 @@ describe("loader", function() {
query: "?abc.def.ghi=>1"
}, "").should.be.eql(HEADER +
"var abc = (abc || {});\n" +
"abc.def = {};\n" +
"abc.def = abc.def || {};\n" +
Copy link
Member

Choose a reason for hiding this comment

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

@michael-ciniawsky is correct. This should be two tests, the existing plus an additional test to cover the new nesting functionality

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does seem like there should be a test that is not impacted by this change. That probably means adding a test for the case where there is no nesting, or exec the generated code and test its behavior:

describe("when the import is nested", function(){
   it("creates the nested variable", function(){
....
   });
   describe ("when the import is a plugin to an existing library", function(){
        it ("adds the functionality to the library", function (){ 
            expect(some.nested.library.originalProperty).toBeDefined ()
...

That would be a larger refactor to how the tests are structured.

Copy link
Member

Choose a reason for hiding this comment

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

This is my fault for not paying attention when I looked at it originally but as a life rule in JavaScript, don't use eval. Even when it isn't a gigantic gaping security issue, there is always a way to do the same thing without it.

- now tests cover the generated code's behavior instead of testing the literal text of the code
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.

@TiraO Thx 👍 && very much 💯 for the addtional test updates a lot better now

@michael-ciniawsky michael-ciniawsky merged commit 44d6f48 into webpack-contrib:master Mar 30, 2017
@michael-ciniawsky
Copy link
Member

@TiraO Can you give me a brief usage example for the docs please, I will overhaul the README today before next release

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

5 participants