diff --git a/packages/editor/scripts/postbuild.mjs b/packages/editor/scripts/postbuild.mjs index 89a426e16..4587599c6 100644 --- a/packages/editor/scripts/postbuild.mjs +++ b/packages/editor/scripts/postbuild.mjs @@ -27,33 +27,29 @@ const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); const ROOT_DIR = path.resolve(path.join(__dirname, "..")); const DIST_DIR = path.resolve(ROOT_DIR, "dist"); -const CJS_BUNDLE_PATH = path.resolve(ROOT_DIR, "dist", "index.js"); -const MJS_BUNDLE_PATH = path.resolve(ROOT_DIR, "dist", "index.mjs"); const ICONS_MJS_BUNDLE_PATH = path.resolve( ROOT_DIR, "dist", + "esm", "toolbar", - "icons.mjs" + "icons.js" ); const ICONS_CJS_BUNDLE_PATH = path.resolve( ROOT_DIR, "dist", + "cjs", "toolbar", "icons.js" ); if ( !fs.existsSync(DIST_DIR) || - !fs.existsSync(CJS_BUNDLE_PATH) || - !fs.existsSync(MJS_BUNDLE_PATH) || !fs.existsSync(ICONS_MJS_BUNDLE_PATH) || !fs.existsSync(ICONS_CJS_BUNDLE_PATH) ) throw new Error("Please build the editor before running this script."); for (const bundle of [ - { type: "cjs", path: CJS_BUNDLE_PATH }, - { type: "mjs", path: MJS_BUNDLE_PATH }, { type: "cjs", path: ICONS_CJS_BUNDLE_PATH }, { type: "mjs", path: ICONS_MJS_BUNDLE_PATH } ]) { @@ -72,7 +68,11 @@ for (const bundle of [ console.log("Removing @mdi/js import..."); - ICON_FILE = ICON_FILE.replace(/var.+=\s+require\(['"]@mdi\/js['"]\);/gm, ""); + ICON_FILE = ICON_FILE.replace(/^import \{.+ } from "@mdi\/js";/gm, ""); + ICON_FILE = ICON_FILE.replace( + /(var|const|let).+=\s+require\(['"]@mdi\/js['"]\);/gm, + "" + ); console.log("Saving file...");