Git Product home page Git Product logo

Comments (4)

benoror avatar benoror commented on June 4, 2024 1

FWIW my recent refactor was mainly based on these ideas:

http://angular-tips.com/blog/2015/06/using-angular-1-dot-x-with-es6-and-webpack/

I basically have several files per module, let's say home module:

  • index.js: Entry point for CommonJS. Load dependencies for the module.
  • home.routes.js: Route(s)
  • home.controller.js: Component's controller (ES6 class)
  • home.html: Template
  • home.css: Stylesheet

As for directives I still use functions as suggested in the article.

*AFAIK having the same dependency injected in different places doesn't matter, since Webpack will handle it

from ama.

kentcdodds avatar kentcdodds commented on June 4, 2024

This is true. Technically, it doesn't make a difference because angular's $injector is a single global context. In my application, I actually have a module for every state of the application and then the 'app' module depends on all of the "state modules." This allows me to have dependencies closer to where they're being used. I also have a concept of ngCommon modules that contain common things throughout a state and the state's children.

My app structure and directory structure are influenced heavily by this gist by @ryanflorence and @mzabriskie. I have to do some pretty interesting things with webpack to get this to work in an angular context... Maybe one day I'll have a blogpost on this or I'll continue to work on the webpack series.

I recently had a failed refactor which attempted to create a single angular module per component (directive/service/etc.) in my app. It was going to be awesome because I could sort-of make my Angular 1 stuff like React or Angular 2 where you have to explicitly list your dependencies (a big win for several reasons). Unfortunately, I got to around 500 modules and noticed bootstrapping time took upwards of 5 seconds 😵 Not sure what the problem was, but it was totally not worth it in any case.

Hope this is helpful! I'm sorry I can't be more helpful!

from ama.

kentcdodds avatar kentcdodds commented on June 4, 2024

👍 thanks @benoror!

from ama.

ondrasak avatar ondrasak commented on June 4, 2024

Thanks @kentcdodds @benoror !

from ama.

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.