How about a real module system?

Discussion in 'Mod Discussions' started by ORFJackal, February 11, 2014.

  1. ORFJackal

    ORFJackal Active Member

    Messages:
    287
    Likes Received:
    248
    PA starts having more and more mods that depend on other mods. They would benefit from a real JavaScript module system (http://requirejs.org/docs/whyamd.html) for managing those dependencies. Then the right order of loading mods would happen automatically, and the mods would be better isolated. See the aforementioned link for more bemefits.
  2. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    Big fan of requirejs - I'll probably use it at least during development if I make any significant mods. At the mod manager level we might need some version awareness as well.
  3. ORFJackal

    ORFJackal Active Member

    Messages:
    287
    Likes Received:
    248
    There has been some talk from Uber about improving PA's moddability. I'm hoping that incorporating a module system could be done as part of those efforts. But it would also be worthwhile to explore modularization within the current modding system, without changes to PA.
  4. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    I made a technical test and RequireJS seems to work. One particular point of curiosity was error reporting - require-loaded files will report file and line numbers, addressing a frustration I have with the builtin loading system.

    https://github.com/JustinLove/pa_requirejs_test

    (Since this is a tech test, all it does is console.log stuff.)

    Actually using it in the current system would need something to manage the global functions:
    ORFJackal likes this.
  5. cwarner7264

    cwarner7264 Moderator Alumni

    Messages:
    4,460
    Likes Received:
    5,390
    ORF would be pleased to talk to you about this at some point relating to the Realm pack and dependencies...
  6. ORFJackal

    ORFJackal Active Member

    Messages:
    287
    Likes Received:
    248
    Sure. What would be a good channel for talking? Forums, email, TeamSpeak?
  7. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    Sorry, I never thought to watch the thread and the messages were fairly innocuous in the stream.

    I downloaded TeamSpeak after hearing about it so much, but don't know which servers are used. Forums would be good in case someone else wanted to chime in, not that many have.
  8. cwarner7264

    cwarner7264 Moderator Alumni

    Messages:
    4,460
    Likes Received:
    5,390
    What do you mean? Who are you looking to communicate with via Teamspeak? That would dictate which server you'd be using.
  9. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    ORF Jackel in this case.
  10. cwarner7264

    cwarner7264 Moderator Alumni

    Messages:
    4,460
    Likes Received:
    5,390
    He'll be on the Realm's teamspeak - I'm on mobile ATM so can't help but hopefully if you PM him he'll give you the IP
  11. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    Looks like the status for now is:

    There is some ambiguity about what the Realm Pack is; perhaps that needs it's own thread. I'm currently working on using RequireJS internally within Gross Economy, and then stripping it out for release. Hopefully this will provide a useful example for further discussion.
  12. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
  13. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    Looks like developing with RequireJS directly requires the "disable cache" setting in the debugger.
  14. cptconundrum

    cptconundrum Post Master General

    Messages:
    4,186
    Likes Received:
    4,900
    What if you do this?

    require("script.js?timestamp=" + Date.now());

    Wouldn't that force it to load the file even if it has a cached version?
  15. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    I'd actually have to hack require.js to do that. And besides, disable cache is easier.
  16. cptconundrum

    cptconundrum Post Master General

    Messages:
    4,186
    Likes Received:
    4,900
    http://stackoverflow.com/questions/8315088/prevent-requirejs-from-caching-required-scripts

    This is the better way to do it. Otherwise, wouldn't all users of the mod need to run coherent without the cache?
  17. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    Thanks for the link, I'll look into it.

    It's only relevant for developers, not users. First because users won't be rapidly changing files while the game is running. Second because I'm currently stripping AMD for release.
    cptconundrum likes this.
  18. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    I think I see AMD in the Galactic War stuff. Will investigate further, and see if breaks my mod version.
  19. proeleert

    proeleert Post Master General

    Messages:
    1,681
    Likes Received:
    1,656
    yeah require.js is in.
    It messed up some of my stuff too.
  20. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    Blunderful - it's loaded everywhere but only configured in GW rooted in GW. Maybe that sort of works the way scenes are isolated.

Share This Page