Frontmatter
| id | 3157 |
| title | src/main/addon in workspace directory |
| state | Closed |
| labels | enhancement |
| assignees | [] |
| createdAt | Jun 15, 2022, 5:42 PM |
| updatedAt | Jul 3, 2022, 7:18 AM |
| githubUrl | https://github.com/neomjs/neo/issues/3157 |
| author | Dinkh |
| commentsCount | 4 |
| parentIssue | null |
| subIssues | [] |
| subIssuesCompleted | 0 |
| subIssuesTotal | 0 |
| blockedBy | [] |
| blocking | [] |
| closedAt | Jul 3, 2022, 7:18 AM |
src/main/addon in workspace directory

some thoughts on my end: for consistency reasons as well as from a logical perspective, main thread addons should not live within the app folder(s).
so my idea for this one is: workspace/src/main/addon/XYZ.mjs.
now the tricky part: we add main thread addons within the neo-config.json files => string based. we do not want to try a dynamic import on framework level and in case it fails, try the workspace based scope. not needed requests make little sense.
to keep the current API, my idea would be to add a prefix for workspace based addons. example (within the config file):
"mainThreadAddons": ["DragDrop", "Stylesheet", "workspace/MyAddon"]
using the workspace/ prefix, it would be clear that this file needs to get dynamically imported from the workspace scope. we would need to adjust the program options (help) and document how to use it.
thoughts?

Very cool idea.
In addition we could add package, so that different apps can go for the same components. How about packages as in ExtJS packages.
We add a folder to the workspace, named packages and in the neo-config.json you can add
"packages": ["myPackage"]
This comes with it's own NameSpace and is usage from all apps. If we go that way we can add the addons to a package, which includes all addOns?
thoughts?

ok, i take it as a yes for the workspace/ prefix :)
one hint: you need to stop thinking in legacy tech. a neo workspace already is a npm package. you can simply add a dependency inside one workspace (package.json) to add another workspace.
you could / should create components inside the source folder there and you can create demo-apps to show how to use your custom components (or other classes) there as well.
nested workspace based theming is not supported yet. i mentioned this one inside one of my blog posts. in case there is no ticket for this one created yet, feel free to add it.

implementation done. shortened the prefix to /WS.
example usage:
mainThreadAddons: ['DragDrop', 'Stylesheet', 'WS/MyAddon']
I would like to add a main thread addon to a project / app.
Currently I have to add a new file to neoSrc.main.addon for some functioniality. It would be cool to be able to add this to appFolder.main.addon