GithubHelp home page GithubHelp logo

Comments (3)

bhgames avatar bhgames commented on May 29, 2024 1

@greypants I've tried using require-dir so I dont have to manually include every directive, controller, and service file in my app(of which there are nearly 100.) It doesn't work because fs doesn't work on the frontend. How do I require all the files?

from gulp-rails-pipeline.

greypants avatar greypants commented on May 29, 2024

It's actually not RequireJS, it's CommonJS style modules. Yeah, part of the point of modules is that you don't have to namespace anymore - nothing is exposed on the window, and everything is explicitly required.

# javascripts/models/monkey.js.coffee
module.exports = class Monkey
  constructor: (@name) ->
    # do some setup
# javascripts/models/zoo.js.coffee
Monkey = require('./monkey.js.coffee')

module.exports = class Zoo
  constructor: () ->
    monkey = new Monkey("Charley")
    # ...

I wrote a little blurb on modules on my gulp-starter wiki: https://github.com/greypants/gulp-starter/wiki/What-is-a-Module%3F

That might help. If you reaaally wanted to rely on globals and namespaces, you can just change App to window.App and use the require-dir module. But that kind of misses the point.

from gulp-rails-pipeline.

bhgames avatar bhgames commented on May 29, 2024

Is it really realistically expected of JS developers to include each one of the hundreds of files they inevitably have in a large project, one at a time? I have been stuck for hours and feel I am missing something here.

from gulp-rails-pipeline.

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.