Coder Social home page Coder Social logo

Comments (8)

jedwards1211 avatar jedwards1211 commented on September 23, 2024

The deps are in an awkward state actually, I've been thinking about it. dependencies get installed for an npm package and any packages that depend on it. devDependencies only get installed for the package itself -- only when you npm install in that package's folder. But it would be weird to use this project as an npm package (i.e. npm install --save meteor-webpack-react) so I'm thinking we should move all the deps to one or the other.

Webpack externals doesn't quite work like that -- rather, if one webpack bundle marks react as an external, react doesn't get built into that bundle but it's still able to require it from the host webpack bundle or something like that (I don't know enough to be technically precise about it).

Webpack as a resolve.alias option that would work for sharing underscore. We could do it like this:

exportUnderscore.js:

export default window._;

webpack config:

{
  resolve: {
    alias: {
      'underscore$': path.join(__dirname, './exportUnderscore.js');
    }
  }
}

from meteor-webpack-react.

jedwards1211 avatar jedwards1211 commented on September 23, 2024

Oh yeah, and right now I'm pretty sure lodash is only being used to extend the webpack configs, for instance in webpack.config.client.dev.js, which means it's not actually being built into the bundles :)

from meteor-webpack-react.

AdamBrodzinski avatar AdamBrodzinski commented on September 23, 2024

Oooh right I keep forgetting it doesn't get bundled unless you require it 😄

Using resolve for underscore might be useful if you want to do import {map, reduce} from 'underscore'; though. Not sure if it should be for the boilerplate though. The only part that makes think it should is that Meteor has a hard dependency on it so it'll be available regardless. I guess you could still do const {map, reduce} = _;

from meteor-webpack-react.

jedwards1211 avatar jedwards1211 commented on September 23, 2024

Actually the import syntax probably should work! Because it would just transpile to something equivalent to require('underscore').map etc. The only problem is requiring internals like react/lib/... for instance.

from meteor-webpack-react.

jedwards1211 avatar jedwards1211 commented on September 23, 2024

Actually, we should be using

externals: {
  'underscore$': {
    root: '_',
  }
}

And I think we might as well go ahead and put this in the configs. I'm busy preparing a prototype for a demo so I don't have much time to fiddle with this project this week, but hopefully next week I can set up releases and get a lot of these issues knocked out.

from meteor-webpack-react.

AdamBrodzinski avatar AdamBrodzinski commented on September 23, 2024

Closing this (unless you think it should still be open), its worth noting that the underscore Meteor uses is super old so using the latest lo-dash offers someone semver, modular builds and more features (what i'm currently doing).

from meteor-webpack-react.

jedwards1211 avatar jedwards1211 commented on September 23, 2024

Heh, I wonder if they depend on some old behavior that got fixed? Oh well, probably not that many kb anyway

from meteor-webpack-react.

AdamBrodzinski avatar AdamBrodzinski commented on September 23, 2024

Yea they tried upgrading but minor bumps would break meteor core so it's frozen to a 2013 version lol. They talked about migrating to lodash eventually but it was low on their priorities

from meteor-webpack-react.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.