From eb741fa526037bb78e75ab6cdda3f1476fdd8237 Mon Sep 17 00:00:00 2001 From: juah255 Date: Fri, 24 Apr 2026 17:52:47 +0600 Subject: [PATCH] replace commmonjs2 to module for export --- package.json | 8 ++++---- webpack.config.js | 15 +++++++++++++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 5357109..d828a4e 100644 --- a/package.json +++ b/package.json @@ -2,8 +2,8 @@ "name": "@wedevs/plugin-ui", "version": "2.0.0", "description": "Scoped, themeable UI components for WordPress plugins - ShadCN style", - "main": "dist/index.js", - "module": "dist/index.js", + "main": "dist/index.mjs", + "module": "dist/index.mjs", "types": "dist/index.d.ts", "sideEffects": [ "**/*.css" @@ -11,8 +11,8 @@ "exports": { ".": { "types": "./dist/index.d.ts", - "import": "./dist/index.js", - "require": "./dist/index.js" + "import": "./dist/index.mjs", + "require": "./dist/index.mjs" }, "./components/ui": { "types": "./dist/components/ui/index.d.ts", diff --git a/webpack.config.js b/webpack.config.js index 2c04523..065b502 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -7,12 +7,23 @@ module.exports = { entry: { index: './src/index.ts', }, + experiments: { + ...( defaultConfig.experiments || {} ), + outputModule: true, + }, output: { ...defaultConfig.output, path: path.resolve( __dirname, 'dist' ), - filename: '[name].js', + filename: '[name].mjs', library: { - type: 'commonjs2', + type: 'module', + }, + module: true, + chunkFormat: 'module', + environment: { + ...( defaultConfig.output?.environment || {} ), + module: true, + dynamicImport: true, }, clean: true, },