Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How To : Organizing javascript in a asp.net core modularized application (modules in dlls) #106

Open
mkgn opened this issue Apr 6, 2021 · 3 comments

Comments

@mkgn
Copy link

mkgn commented Apr 6, 2021

My Application is organized in a way that some features are working as a plugin. Each plugin has it's own APIs, Views, Static files etc.. I am using ViewLocationExpander to find the view files owned by plugins which is not in the standard location but in the plugins relative path. Example;

[Starting MVC Application]
|__MainLayOut
|__Modules
    |__Plugin1
        |_Binaries
        |_Views (has shared, _viewimports etc.. local to this module)
        |_wwwroot (has static files local to this module)
    |
    |__Plugin2
        |_Binaries
        |_Views (has shared, _viewimports etc.. local to this module)
        |_wwwroot (has static files local to this module)

As you see in above structure if you delete the a plugin from the Modules folder entire plugin related features will get deactivated. So code for that plugin is 100% within the plugin directory.

Now I am planning to use RequireJS and try to modularize javascripts that is needed by each plugin. However the doucment says:

The requirejs entrypoint for each page will be loaded from ~/Scripts/Controllers/{area}/{controller}/{action}

But in my case RequireJS should be able to load the JS file not from the primary ~/Scripts folder but the /wwwroot/js folder which is inside the Plugin folder (\Modules\Plugin1\wwwroot\js). If I can get this done (May be like ViewLocationExpander), I can have a 100% modularized app.

Is this possible?

@davidsk
Copy link
Contributor

davidsk commented Apr 6, 2021

I think the section titled "OVERRIDING ENTRYPOINT RESOLUTION" here: http://requirejsnet.veritech.io/setup.html may be of help. Essentially you can implement your own logic for locating an Entrypoint script

@mkgn
Copy link
Author

mkgn commented Apr 6, 2021

I forgot to mention that I am on .Net 5 and this is not yet ported to support it officially right? However I found : https://github.com/davidsk/RequireJSDotNet/blob/RequireJsDotNet_Core1.0/MVC6/Startup.cs which seems to use the resolver you mention above. Is this what you were talking about? Do you have a plan to officially support .Net 5?

@davidsk
Copy link
Contributor

davidsk commented Apr 6, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants