Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ const docsifyConfig = {
outputName: 'docsify',
title: 'Docsify',
};
const docsifyEsmConfig = {
inputPath: 'src/core/module.js',
outputDir: 'dist',
outputName: 'docsify.esm',
title: 'Docsify',
format: 'es',
};

// Plugins
const pluginPaths = await glob(['src/plugins/*.js', 'src/plugins/*/index.js']);
Expand Down Expand Up @@ -65,8 +72,9 @@ const baseConfig = {
const bundleConfigs = [];

// Generate rollup configurations
[docsifyConfig, ...pluginConfigs].forEach(bundleConfig => {
const { inputPath, outputDir, outputName, title } = bundleConfig;
[docsifyConfig, docsifyEsmConfig, ...pluginConfigs].forEach(bundleConfig => {
const { inputPath, outputDir, outputName, title, format } = bundleConfig;
const outputFormat = format || baseConfig.output.format;
// prettier-ignore
const banner = stripIndent`
/*!
Expand All @@ -83,6 +91,7 @@ const bundleConfigs = [];
...baseConfig.output,
banner,
file: path.join(outputDir, `${outputName}.min.js`),
format: outputFormat,
sourcemap: true,
},
plugins: [
Expand All @@ -101,6 +110,7 @@ const bundleConfigs = [];
...baseConfig.output,
banner,
file: path.join(outputDir, `${outputName}.js`),
format: outputFormat,
},
plugins: [
...baseConfig.plugins,
Expand Down
4 changes: 3 additions & 1 deletion test/consume-types/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ await import('prismjs');
// Prism being global is not statically analyzable by the ES Module system so it
// will try to execute Docsify's graph before prism.js has finished executed.
// This is very odd, I didn't think this was possible.
const { Docsify } = await import('docsify');
const { Compiler, Docsify, dom, get, marked, prism, slugify, util, version } =
await import('docsify');

const d = new Docsify({
el: '#app',
Expand All @@ -39,6 +40,7 @@ const d = new Docsify({
});

console.log(d);
console.log(Compiler, dom, get, marked, prism, slugify, util, version);

// @ts-expect-error global types not available to ESM
window.Docsify;
Expand Down
Loading