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

meta tags manager #123

Merged
merged 4 commits into from
Oct 16, 2015
Merged

meta tags manager #123

merged 4 commits into from
Oct 16, 2015

Conversation

justin808
Copy link
Member

No description provided.

josiasds and others added 3 commits October 15, 2015 14:58
Set engines node: 4.2.0 in all package.jsons'
Install node_modules with npm 3.3.6
npm shrinkwrap to create new npm-shinkwrap.json
return meta.getAttribute('content');
}
}
const token = Array.from(document.getElementsByTagName('meta'))
Copy link
Member Author

Choose a reason for hiding this comment

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

@josiasds Let's consider the lodash syntax from this.

Interesting find from @dylangrafmyre on the CI regarding Array.from.

Copy link
Member

Choose a reason for hiding this comment

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

@justin808 I'm not sure we should add lodash only to replace Array.from by _.toArray.

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right. We don't have lodash in this project.

_.find(document.getElementsByTagName('meta'), tag => tag.name === 'csrf-token')

or

_(document.getElementsByTagName('meta')).find(tag => tag.name === 'csrf-token')

2015-10-16_12-09-15

I really like Lodash. I wouldn't suggest this otherwise. That being said, we don't need it give some features in ES6.

Because I want this example to be a real starter kit showing off Webpack/Npm/React integration, I think this is worth considering.

Let's see what @mapreal19, @alexfedoseev, @samnang, @dylangrafmyre Think about this one.

Copy link
Member Author

Choose a reason for hiding this comment

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

Even better from the lodash source, @jdalton:

_.find(document.querySelectorAll('meta'), 'name', 'csrf-token')

justin808 added a commit that referenced this pull request Oct 16, 2015
meta tags manager using ES6 Array.from and upgrade to Node 4.2
@justin808 justin808 merged commit 753440e into master Oct 16, 2015
@justin808
Copy link
Member Author

@josiasds We can consider adding Lodash in a future PR.

@josiasds
Copy link
Member

@justin808 👍

@justin808
Copy link
Member Author

See #124

@alex35mil
Copy link
Member

My decision making chart:

Can I use Immutable.js in this project?
            ⇙           ⇘
         Yes             No
       ⇙                    ⇘
Immutable.js               Lodash

@justin808
Copy link
Member Author

@alexfedoseev Why would you avoid lodash if you're using immutable.js? We're already including lodash through a dependency of dependency.

@alex35mil
Copy link
Member

Because every Immutable instance already has all necessary methods in its prototype to handle the data transformations.

@alex35mil
Copy link
Member

Btw, in this case it's better to use not npm i --save lodash but npm i --save lodash.find to include only actually used lodash's method & reduce total build size.

@jdalton
Copy link

jdalton commented Oct 17, 2015

require('lodash/collection/find')

@alex35mil
Copy link
Member

@jdalton 👍

@justin808
Copy link
Member Author

@alexfedoseev do wepacks optimizations strip out unnecessary libs?

@jdalton
Copy link

jdalton commented Oct 18, 2015

If you cherry-pick, then yes.

@justin808
Copy link
Member Author

@jdalton by cherry pick, you mean with the

require('lodash/collection/find')

and can we include npm i --save lodash or do we need to do npm i --save lodash.find

Incidentally, this project is already including lodash as a dependency of a dependency.

@alex35mil
Copy link
Member

and can we include npm i --save lodash or do we need to do npm i --save lodash.find

If we'll do npm i --save lodash, then we can:

import _find from 'lodash/collection/find';

If we'll do npm i --save lodash.find then we can:

import _find from 'lodash.find';

Result will be the same. Only difference is if lodash will be installed, then we don't have to add stand-alone modules to package.json (like lodash.find). We can just cherry-pick them from lodash/collection dir.

@jdalton correct me if I'm wrong.

Incidentally, this project is already including lodash as a dependency of a dependency.

I don't think it's a good idea to rely on such dependency, because we can't control it (it can be changed or removed from this package in the future versions). We should define this dependency implicitly. If lodash packages will be identical, then webpack.optimize.DedupePlugin should handle it.

@rstudner
Copy link
Contributor

Immutable.js > Lodash if we are talking about going into the future. (I love lodash, that isn't the point)

That being said, if we are going to use lodash, we 100% have to explicitly depend on it and not rely on a 3rd party library pulling it in.

@justin808 justin808 deleted the josias-meta-tags-manager branch October 18, 2015 21:27
@jdalton
Copy link

jdalton commented Oct 20, 2015

Immutable.js > Lodash if we are talking about going into the future.

ok

@justin808
Copy link
Member Author

👍 👍 👍

@jdalton it would be nice if there was some way that we could use Lodash API's with immutable objects. We're prefixing the names of our immutable objects with $$, like $$users to indicate a immutable list of users. We ran into many bugs from forgetting to use the Immutable rather than the native JS APIs.

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.

6 participants