Skip to content

Suggestions for Workers and Models #2

@ZeroThe2nd

Description

@ZeroThe2nd

When using ant with systems like VueJS in a component structure, it's hard to use fixed paths to models and workers. The workers have to be copied, then imported, and models are always loaded by file path.

ANT plays nice with module a node module system, however still relies on these paths. This causes issues when used with a compiler like Webpack or such. The way these are imported, it's also simply not possible to use something like worker-loader to compile an application into a production ready, minimised file, hence there's always a need to add the 4 separate files into the project as uncompiled code. This also makes updating the package harder in the future as the files need to be copied on every build to ensure it's the latest version.

Suggestion: Use Freelancer, Blobs or this SO post to create service workers without needing a file path.

Suggestion: Allow models to be imported by Object reference:

import UserModel from 'Models/User'
ANT.init({
  models: { // Instead of modelsPaths to keep it compatible
    User: UserModel
  }
})

I currently haven't had the time to dig through all the code, but I'd love to try and improve on it. I'll make a PR if I've made some progress. Are you able to provide a test script of sorts I can use as a verification that everything still works as required?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions