From 0a944a5de159103665860d902859fbaf55c33652 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Tue, 20 Sep 2022 21:54:32 +0530 Subject: [PATCH] Revert "Add diagramAPI to outfile" This reverts commit a87abc00c65de91ed417e25c5f81973673f21153. --- .esbuild/serve.cjs | 13 ++++++++----- .esbuild/util.cjs | 19 +++++-------------- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/.esbuild/serve.cjs b/.esbuild/serve.cjs index f39491855..7f00215f7 100644 --- a/.esbuild/serve.cjs +++ b/.esbuild/serve.cjs @@ -1,6 +1,6 @@ const esbuild = require('esbuild'); const http = require('http'); -const { iifeBuild, esmBuild, getEntryPoints } = require('./util.cjs'); +const { iifeBuild, esmBuild } = require('./util.cjs'); const express = require('express'); // Start 2 esbuild servers. One for IIFE and one for ESM @@ -13,11 +13,11 @@ const express = require('express'); const getEntryPointsAndExtensions = (format) => { return { entryPoints: { - ...getEntryPoints(format === 'iife' ? '' : '.esm'), + mermaid: './src/mermaid', e2e: 'cypress/platform/viewer.js', 'bundle-test': 'cypress/platform/bundle-test.js', }, - outExtension: { '.js': format === 'iife' ? '.js' : '.mjs' }, + outExtension: { '.js': format === 'iife' ? '.js' : '.esm.mjs' }, }; }; @@ -53,13 +53,16 @@ const generateHandler = (server) => { const iifeServer = await esbuild.serve( {}, { - ...iifeBuild({ minify: false }), + ...iifeBuild({ minify: false, outfile: undefined, outdir: 'dist' }), ...getEntryPointsAndExtensions('iife'), } ); const esmServer = await esbuild.serve( {}, - { ...esmBuild({ minify: false }), ...getEntryPointsAndExtensions('esm') } + { + ...esmBuild({ minify: false, outfile: undefined, outdir: 'dist' }), + ...getEntryPointsAndExtensions('esm'), + } ); const app = express(); diff --git a/.esbuild/util.cjs b/.esbuild/util.cjs index 49b8e3d10..4dbcd01c3 100644 --- a/.esbuild/util.cjs +++ b/.esbuild/util.cjs @@ -19,21 +19,14 @@ const buildOptions = (override = {}) => { tsconfig: 'tsconfig.json', resolveExtensions: ['.ts', '.js', '.mjs', '.json', '.jison'], external: ['require', 'fs', 'path'], - outdir: 'dist', + entryPoints: ['src/mermaid.ts'], + outfile: 'dist/mermaid.min.js', plugins: [jisonPlugin], sourcemap: 'external', ...override, }; }; -const getEntryPoints = (extension) => { - return { - [`mermaid${extension}`]: 'src/mermaid.ts', - [`diagramAPI${extension}`]: 'src/diagram-api/diagramAPI.ts', - }; -}; -exports.getEntryPoints = getEntryPoints; - /** * Build options for mermaid.esm.* build. * @@ -45,8 +38,7 @@ exports.getEntryPoints = getEntryPoints; exports.esmBuild = (override = { minify: true }) => { return buildOptions({ format: 'esm', - entryPoints: getEntryPoints(`.esm${override.minify ? '.min' : ''}`), - outExtension: { '.js': '.mjs' }, + outfile: `dist/mermaid.esm${override.minify ? '.min' : ''}.mjs`, ...override, }); }; @@ -63,8 +55,7 @@ exports.esmBuild = (override = { minify: true }) => { exports.esmCoreBuild = (override) => { return buildOptions({ format: 'esm', - entryPoints: getEntryPoints(`.core`), - outExtension: { '.js': '.mjs' }, + outfile: `dist/mermaid.core.mjs`, external: ['require', 'fs', 'path', ...Object.keys(dependencies)], platform: 'neutral', ...override, @@ -81,7 +72,7 @@ exports.esmCoreBuild = (override) => { */ exports.iifeBuild = (override = { minify: true }) => { return buildOptions({ - entryPoints: getEntryPoints(override.minify ? '.min' : ''), + outfile: `dist/mermaid${override.minify ? '.min' : ''}.js`, format: 'iife', footer: { js: 'mermaid = mermaid.default;',