From 1e71798467e3fa2e1483873d9b33d93016fe6b4d Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Fri, 23 Sep 2022 17:20:40 +0530 Subject: [PATCH] fix: Core build --- .vite/build.ts | 18 +++++++++++------- src/mermaid.ts | 1 - 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.vite/build.ts b/.vite/build.ts index ed99421f6..c4df49ea2 100644 --- a/.vite/build.ts +++ b/.vite/build.ts @@ -36,13 +36,17 @@ export const getBuildConfig = ({ minify, core, watch }: BuildOptions): InlineCon ]; if (core) { + // Core build is used to generate file without bundled dependencies. + // This is used by downstream projects to bundle dependencies themselves. external.push(...Object.keys(dependencies)); - output = { - name: 'mermaid', - format: 'esm', - sourcemap: true, - entryFileNames: `[name].core.mjs`, - }; + // This needs to be an array. Otherwise vite will build esm & umd with same name and overwrite esm with umd. + output = [ + { + format: 'esm', + sourcemap: true, + entryFileNames: `[name].core.mjs`, + }, + ]; } const config: InlineConfig = { @@ -81,5 +85,5 @@ if (watch) { } else { build(getBuildConfig({ minify: false })); build(getBuildConfig({ minify: 'esbuild' })); - build(getBuildConfig({ minify: true, core: true })); + build(getBuildConfig({ minify: false, core: true })); } diff --git a/src/mermaid.ts b/src/mermaid.ts index 6eec7ea66..809387f60 100644 --- a/src/mermaid.ts +++ b/src/mermaid.ts @@ -1,4 +1,3 @@ -'use strict'; /** * Web page integration module for the mermaid framework. It uses the mermaidAPI for mermaid * functionality and to render the diagrams to svg code.