Add diagramAPI to outfile
This commit is contained in:
parent
d8735060dc
commit
a87abc00c6
|
@ -19,14 +19,19 @@ const buildOptions = (override = {}) => {
|
||||||
tsconfig: 'tsconfig.json',
|
tsconfig: 'tsconfig.json',
|
||||||
resolveExtensions: ['.ts', '.js', '.json', '.jison'],
|
resolveExtensions: ['.ts', '.js', '.json', '.jison'],
|
||||||
external: ['require', 'fs', 'path'],
|
external: ['require', 'fs', 'path'],
|
||||||
entryPoints: ['src/mermaid.ts'],
|
outdir: 'dist',
|
||||||
outfile: 'dist/mermaid.min.js',
|
|
||||||
plugins: [jisonPlugin],
|
plugins: [jisonPlugin],
|
||||||
sourcemap: 'external',
|
sourcemap: 'external',
|
||||||
...override,
|
...override,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getOutFiles = (extension) => {
|
||||||
|
return {
|
||||||
|
[`mermaid${extension}`]: 'src/mermaid.ts',
|
||||||
|
[`diagramAPI${extension}`]: 'src/diagram-api/diagramAPI.ts',
|
||||||
|
};
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* Build options for mermaid.esm.* build.
|
* Build options for mermaid.esm.* build.
|
||||||
*
|
*
|
||||||
|
@ -38,7 +43,8 @@ const buildOptions = (override = {}) => {
|
||||||
exports.esmBuild = (override = { minify: true }) => {
|
exports.esmBuild = (override = { minify: true }) => {
|
||||||
return buildOptions({
|
return buildOptions({
|
||||||
format: 'esm',
|
format: 'esm',
|
||||||
outfile: `dist/mermaid.esm${override.minify ? '.min' : ''}.mjs`,
|
entryPoints: getOutFiles(`.esm${override.minify ? '.min' : ''}`),
|
||||||
|
outExtension: { '.js': '.mjs' },
|
||||||
...override,
|
...override,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -46,8 +52,8 @@ exports.esmBuild = (override = { minify: true }) => {
|
||||||
/**
|
/**
|
||||||
* Build options for mermaid.core.* build.
|
* Build options for mermaid.core.* build.
|
||||||
*
|
*
|
||||||
* This build does not bundle `./node_modules/`, as it is designed to be used
|
* This build does not bundle `./node_modules/`, as it is designed to be used with
|
||||||
* with Webpack/ESBuild/Vite to use mermaid inside an app/website.
|
* Webpack/ESBuild/Vite to use mermaid inside an app/website.
|
||||||
*
|
*
|
||||||
* @param {Options} override - Override options.
|
* @param {Options} override - Override options.
|
||||||
* @returns {Options} ESBuild build options.
|
* @returns {Options} ESBuild build options.
|
||||||
|
@ -55,7 +61,8 @@ exports.esmBuild = (override = { minify: true }) => {
|
||||||
exports.esmCoreBuild = (override) => {
|
exports.esmCoreBuild = (override) => {
|
||||||
return buildOptions({
|
return buildOptions({
|
||||||
format: 'esm',
|
format: 'esm',
|
||||||
outfile: `dist/mermaid.core.mjs`,
|
entryPoints: getOutFiles(`.core`),
|
||||||
|
outExtension: { '.js': '.mjs' },
|
||||||
external: ['require', 'fs', 'path', ...Object.keys(dependencies)],
|
external: ['require', 'fs', 'path', ...Object.keys(dependencies)],
|
||||||
platform: 'neutral',
|
platform: 'neutral',
|
||||||
...override,
|
...override,
|
||||||
|
@ -72,7 +79,7 @@ exports.esmCoreBuild = (override) => {
|
||||||
*/
|
*/
|
||||||
exports.iifeBuild = (override = { minify: true }) => {
|
exports.iifeBuild = (override = { minify: true }) => {
|
||||||
return buildOptions({
|
return buildOptions({
|
||||||
outfile: `dist/mermaid${override.minify ? '.min' : ''}.js`,
|
entryPoints: getOutFiles(override.minify ? '.min' : ''),
|
||||||
format: 'iife',
|
format: 'iife',
|
||||||
...override,
|
...override,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue