Browse Source

Fix cjs build and package entries

pull/979/head
Vitaly Puzrin 1 year ago
parent
commit
5347c2d33f
  1. 2
      .eslintrc.yml
  2. 14
      package.json
  3. 10
      support/rollup.config.mjs

2
.eslintrc.yml

@ -18,9 +18,7 @@ ignorePatterns:
- demo/ - demo/
- dist/ - dist/
- node_modules - node_modules
- support/demo_template/sample.js
- benchmark/extra/ - benchmark/extra/
- rollup.config.js
rules: rules:
accessor-pairs: 2 accessor-pairs: 2

14
package.json

@ -11,6 +11,18 @@
], ],
"repository": "markdown-it/markdown-it", "repository": "markdown-it/markdown-it",
"license": "MIT", "license": "MIT",
"main": "dist/markdown-it.js",
"module": "index.mjs",
"exports": {
".": {
"import": "./index.mjs",
"require": "./dist/markdown-it.js"
},
"./*": {
"require": "./*",
"import": "./*"
}
},
"bin": { "bin": {
"markdown-it": "bin/markdown-it.mjs" "markdown-it": "bin/markdown-it.mjs"
}, },
@ -23,7 +35,7 @@
"gh-doc": "npm run doc && gh-pages -d apidoc -f", "gh-doc": "npm run doc && gh-pages -d apidoc -f",
"demo": "npm run lint && node support/build_demo.mjs", "demo": "npm run lint && node support/build_demo.mjs",
"gh-demo": "npm run demo && gh-pages -d demo -f -b master -r git@github.com:markdown-it/markdown-it.github.io.git", "gh-demo": "npm run demo && gh-pages -d demo -f -b master -r git@github.com:markdown-it/markdown-it.github.io.git",
"browserify": "rollup -c support/rollup.config.js", "browserify": "rollup -c support/rollup.config.mjs",
"benchmark-deps": "npm install --prefix benchmark/extra/ -g marked@0.3.6 commonmark@0.26.0 markdown-it/markdown-it.git#2.2.1", "benchmark-deps": "npm install --prefix benchmark/extra/ -g marked@0.3.6 commonmark@0.26.0 markdown-it/markdown-it.git#2.2.1",
"specsplit": "support/specsplit.mjs good -o test/fixtures/commonmark/good.txt && support/specsplit.mjs bad -o test/fixtures/commonmark/bad.txt && support/specsplit.mjs", "specsplit": "support/specsplit.mjs good -o test/fixtures/commonmark/good.txt && support/specsplit.mjs bad -o test/fixtures/commonmark/bad.txt && support/specsplit.mjs",
"todo": "grep 'TODO' -n -r ./lib 2>/dev/null", "todo": "grep 'TODO' -n -r ./lib 2>/dev/null",

10
support/rollup.config.js → support/rollup.config.mjs

@ -1,11 +1,12 @@
import nodeResolve from '@rollup/plugin-node-resolve'; import nodeResolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs'; import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import pkg from '../package.json';
import terser from '@rollup/plugin-terser'; import terser from '@rollup/plugin-terser';
import { readFileSync } from 'fs';
const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url)));
export default { export default {
input: 'index.js', input: 'index.mjs',
output: [ output: [
{ {
file: 'dist/markdown-it.js', file: 'dist/markdown-it.js',
@ -32,7 +33,7 @@ export default {
plugins: [ plugins: [
terser({ terser({
format: { format: {
ascii_only: true, ascii_only: true
} }
}) })
] ]
@ -41,7 +42,6 @@ export default {
plugins: [ plugins: [
nodeResolve({ preferBuiltins: true }), nodeResolve({ preferBuiltins: true }),
commonjs(), commonjs(),
json({ namedExports: false }),
{ {
banner() { banner() {
return `/*! ${pkg.name} ${pkg.version} https://github.com/${pkg.repository} @license ${pkg.license} */`; return `/*! ${pkg.name} ${pkg.version} https://github.com/${pkg.repository} @license ${pkg.license} */`;
Loading…
Cancel
Save