Browse Source

Support ES Module output in npm package. #862

pull/863/head
Paul Irwin 3 years ago
parent
commit
3ebf37cc42
  1. 2
      package.json
  2. 48
      support/rollup.config.js

2
package.json

@ -12,10 +12,12 @@
"repository": "markdown-it/markdown-it", "repository": "markdown-it/markdown-it",
"license": "MIT", "license": "MIT",
"main": "index.js", "main": "index.js",
"module": "dist/esm/markdown-it.mjs",
"bin": { "bin": {
"markdown-it": "bin/markdown-it.js" "markdown-it": "bin/markdown-it.js"
}, },
"scripts": { "scripts": {
"build": "rollup -c support/rollup.config.js",
"lint": "eslint .", "lint": "eslint .",
"test": "npm run lint && nyc mocha && node support/specsplit.js", "test": "npm run lint && nyc mocha && node support/specsplit.js",
"coverage": "npm run test && nyc report --reporter html", "coverage": "npm run test && nyc report --reporter html",

48
support/rollup.config.js

@ -5,14 +5,7 @@ import nodePolyfills from 'rollup-plugin-node-polyfills';
import pkg from '../package.json'; import pkg from '../package.json';
import { terser } from 'rollup-plugin-terser'; import { terser } from 'rollup-plugin-terser';
export default { const unminifiedPlugins = [
input: 'index.js',
output: [
{
file: 'dist/markdown-it.js',
format: 'umd',
name: 'markdownit',
plugins: [
// Here terser is used only to force ascii output // Here terser is used only to force ascii output
terser({ terser({
mangle: false, mangle: false,
@ -24,19 +17,42 @@ export default {
indent_level: 2 indent_level: 2
} }
}) })
] ];
},
{ const minifiedPlugins = [
file: 'dist/markdown-it.min.js',
format: 'umd',
name: 'markdownit',
plugins: [
terser({ terser({
format: { format: {
ascii_only: true, ascii_only: true,
} }
}) })
] ];
export default {
input: 'index.js',
output: [
{
file: 'dist/markdown-it.js',
format: 'umd',
name: 'markdownit',
plugins: unminifiedPlugins,
},
{
file: 'dist/markdown-it.min.js',
format: 'umd',
name: 'markdownit',
plugins: minifiedPlugins,
},
{
file: 'dist/esm/markdown-it.mjs',
format: 'es',
name: 'markdownit',
plugins: unminifiedPlugins,
},
{
file: 'dist/esm/markdown-it.min.mjs',
format: 'es',
name: 'markdownit',
plugins: minifiedPlugins,
} }
], ],
plugins: [ plugins: [

Loading…
Cancel
Save