Skip to content

Commit

Permalink
Add diagramAPI to outfile
Browse files Browse the repository at this point in the history
  • Loading branch information
sidharthv96 committed Sep 12, 2022
1 parent 54faa80 commit 1b11a06
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
21 changes: 14 additions & 7 deletions .esbuild/util.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,19 @@ const buildOptions = (override = {}) => {
tsconfig: 'tsconfig.json',
resolveExtensions: ['.ts', '.js', '.json', '.jison'],
external: ['require', 'fs', 'path'],
entryPoints: ['src/mermaid.ts'],
outfile: 'dist/mermaid.min.js',
outdir: 'dist',
plugins: [jisonPlugin],
sourcemap: 'external',
...override,
};
};

const getOutFiles = (extension) => {
return {
[`mermaid${extension}`]: 'src/mermaid.ts',
[`diagramAPI${extension}`]: 'src/diagram-api/diagramAPI.ts',
};
};
/**
* Build options for mermaid.esm.* build.
*
Expand All @@ -38,24 +43,26 @@ const buildOptions = (override = {}) => {
exports.esmBuild = (override = { minify: true }) => {
return buildOptions({
format: 'esm',
outfile: `dist/mermaid.esm${override.minify ? '.min' : ''}.mjs`,
entryPoints: getOutFiles(`.esm${override.minify ? '.min' : ''}`),
outExtension: { '.js': '.mjs' },
...override,
});
};

/**
* Build options for mermaid.core.* build.
*
* This build does not bundle `./node_modules/`, as it is designed to be used
* with Webpack/ESBuild/Vite to use mermaid inside an app/website.
* This build does not bundle `./node_modules/`, as it is designed to be used with
* Webpack/ESBuild/Vite to use mermaid inside an app/website.
*
* @param {Options} override - Override options.
* @returns {Options} ESBuild build options.
*/
exports.esmCoreBuild = (override) => {
return buildOptions({
format: 'esm',
outfile: `dist/mermaid.core.mjs`,
entryPoints: getOutFiles(`.core`),
outExtension: { '.js': '.mjs' },
external: ['require', 'fs', 'path', ...Object.keys(dependencies)],
platform: 'neutral',
...override,
Expand All @@ -72,7 +79,7 @@ exports.esmCoreBuild = (override) => {
*/
exports.iifeBuild = (override = { minify: true }) => {
return buildOptions({
outfile: `dist/mermaid${override.minify ? '.min' : ''}.js`,
entryPoints: getOutFiles(override.minify ? '.min' : ''),
format: 'iife',
...override,
});
Expand Down
6 changes: 3 additions & 3 deletions src/diagram-api/diagramAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import { setupGraphViewbox as _setupGraphViewbox } from '../setupGraphViewbox';
import { addStylesForDiagram } from '../styles';

/*
Packaging and exposing resources for externa diagrams so that they can import
diagramAPI and have access to selct parts of mermaid common code reqiored to
create diagrams worling like the internal diagrams.
Packaging and exposing resources for external diagrams so that they can import
diagramAPI and have access to select parts of mermaid common code required to
create diagrams working like the internal diagrams.
*/
export const log = _log;
export const setLogLevel = _setLogLevel;
Expand Down

0 comments on commit 1b11a06

Please sign in to comment.