Thanks @baris for your quick response!
I just tried adding modules but I am puzzled when I found my module is not in build/public/src/modules/
.
I didn't see any relevant error message when my plugin builds, it says there is 1 AMD style module + the plugin is loaded.
The server side of the plugin looks to be working as my breakpoint hits the init()
function of plugin's main JS file.
I used a different module name on purpose to check if it is built but the result is the same.
Wondering do I need to put the scripts and modules JS file inside a directory defined in staticDirs for the browser to have access?
Think that is not the case but I am not sure how to continue debug this.
I have included some of my code snippet below:
...
"main": "src/index.js",
...
...
"scripts": [
"src/public/main.js"
],
"modules": {
"searchv2.js": "src/public/modules/searchv2.js"
}
...
$(document).ready(() => {
function setupSearchModule() {
require(['searchv2'], (search) => {
search.init();
});
}
setupSearchModule();
});
- src/public/modules/searchv2.js
define('searchv2', ['search'], (search) => {
const Searchv2 = {};
Searchv2.init = function () {
if (!config.searchEnabled) {
return;
}
search.showAndFocusInput();
};
return Searchv2;
});
...
const search = module.exports;
search.init = async function (params) {
const { router } = params;
const routeHelpers = require.main.require('./src/routes/helpers');
...
};
...