See: https://www.novaeh.com/2025/04/how-to-fix-circular-dependencies.html
IMPORTANT: Don’t put “type”:”module” in package.json or Webpack won’t bundle.
// Sample Webpack config to bundle as MJS
const path = require("path");
module.exports = {
experiments: {
outputModule: true // To enable MJS
},
entry: './index.js',
output: {
filename: 'wpower.js',
path: path.resolve(__dirname, 'dist'),
module: true, // To parse as MJS
libraryTarget: 'module' // To export as MJS
},
mode: 'production'
};
// EOF
import wpower from "/libs/wpower/wpower.js";
// Unpack in each method, not global, avoid circular issue.
const {ut,ui,lang,net,cvm} = wpower;
The root folder is the root folder Webpack is using.
import ut from "/libs/wpower/ut.js";
import ui from "/libs/wpower/ui.js";
import lang from "/libs/wpower/lang.js";
import net from "/libs/wpower/net.js";
import cvm from "/libs/wpower/cvm/cvm.js";
For project using Wpower with Webpack, the only thing to init is language constants.
Sample phrases file, phrases.js: