Browse Source

browserify => rollup.js

pull/722/head
Vitaly Puzrin 4 years ago
parent
commit
a2cf20d3d3
  1. 1
      .eslintrc.yml
  2. 1
      CHANGELOG.md
  3. 13
      Makefile
  4. 12
      package.json
  5. 5
      support/build_demo.js
  6. 44
      support/demo_template/rollup.config.js
  7. 53
      support/rollup.config.js

1
.eslintrc.yml

@ -10,6 +10,7 @@ ignorePatterns:
- node_modules
- support/demo_template/sample.js
- benchmark/extra/
- rollup.config.js
rules:
accessor-pairs: 2

1
CHANGELOG.md

@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Added 3rd argument to `highlight(code, lang, attrs)`, #626.
- Rewrite tables according to latest GFM spec, #697.
- Use `rollup.js` to browserify sources.
### Fixed
- Fix mappings for table rows (amended fix made in 11.0.1), #705.

13
Makefile

@ -44,19 +44,10 @@ publish:
npm publish ${GITHUB_PROJ}/tarball/${NPM_VERSION}
browserify:
rm -rf ./dist
mkdir dist
# Browserify
( printf "/*! ${NPM_PACKAGE} ${NPM_VERSION} ${GITHUB_PROJ} @license MIT */" ; \
browserify ./ -s markdownit \
) > dist/markdown-it.js
# Minify
terser dist/markdown-it.js -b beautify=false,ascii_only=true -c -m \
--preamble "/*! ${NPM_PACKAGE} ${NPM_VERSION} ${GITHUB_PROJ} @license MIT */" \
> dist/markdown-it.min.js
npm run browserify
benchmark-deps:
npm install --prefix benchmark/extra/ -g marked@0.3.6 commonmark@0.26.0 markdown-it/markdown-it.git#2.2.1
npm run benchmark-deps
specsplit:
./support/specsplit.js good ./test/fixtures/commonmark/spec.txt > ./test/fixtures/commonmark/good.txt

12
package.json

@ -24,6 +24,8 @@
"gh-doc": "npm run doc && gh-pages -d apidoc -f",
"demo": "npm run lint && node support/build_demo.js",
"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",
"benchmark-deps": "npm install --prefix benchmark/extra/ -g marked@0.3.6 commonmark@0.26.0 markdown-it/markdown-it.git#2.2.1",
"prepublishOnly": "npm run gh-demo && npm run gh-doc"
},
"files": [
@ -40,10 +42,12 @@
"uc.micro": "^1.0.5"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^15.1.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^9.0.0",
"ansi": "^0.3.0",
"autoprefixer-stylus": "^1.0.0",
"benchmark": "~2.1.0",
"browserify": "^16.3.0",
"chai": "^4.2.0",
"coveralls": "^3.0.4",
"eslint": "^7.0.0",
@ -65,10 +69,12 @@
"ndoc": "^5.0.0",
"nyc": "^15.0.1",
"pug-cli": "^1.0.0-alpha6",
"rollup": "^2.29.0",
"rollup-plugin-node-polyfills": "^0.2.1",
"rollup-plugin-terser": "^7.0.2",
"shelljs": "^0.8.4",
"stylus": "^0.54.5",
"supertest": "^4.0.2",
"terser": "^4.1.2"
"supertest": "^4.0.2"
},
"mocha": {
"inline-diffs": true

5
support/build_demo.js

@ -21,9 +21,6 @@ shell.exec('node_modules/.bin/stylus -u autoprefixer-stylus \
shell.rm('-rf', 'support/demo_template/sample.json');
shell.exec('node_modules/.bin/browserify ./ -s markdownit \
> demo/markdown-it.js');
shell.exec('node_modules/.bin/browserify support/demo_template/index.js \
> demo/index.js');
shell.exec('node_modules/.bin/rollup -c support/demo_template/rollup.config.js');
shell.cp('support/demo_template/README.md', 'demo/');

44
support/demo_template/rollup.config.js

@ -0,0 +1,44 @@
import nodeResolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import nodePolyfills from 'rollup-plugin-node-polyfills';
import { terser } from 'rollup-plugin-terser';
const plugins = [
nodeResolve({ preferBuiltins: true }),
commonjs(),
json({ namedExports: false }),
nodePolyfills(),
// Here terser is used only to force ascii output
terser({
mangle: false,
compress: false,
format: {
comments: 'all',
beautify: true,
ascii_only: true,
indent_level: 2
}
})
];
export default [
{
input: 'index.js',
output: {
file: 'demo/markdown-it.js',
format: 'umd',
name: 'markdownit'
},
plugins: plugins
},
{
input: 'support/demo_template/index.js',
output: {
file: 'demo/index.js',
format: 'iife',
name: 'demo'
},
plugins: plugins
}
];

53
support/rollup.config.js

@ -0,0 +1,53 @@
import nodeResolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import nodePolyfills from 'rollup-plugin-node-polyfills';
import pkg from '../package.json';
import { terser } from 'rollup-plugin-terser';
export default {
input: 'index.js',
output: [
{
file: 'dist/markdown-it.js',
format: 'umd',
name: 'markdownit',
plugins: [
// Here terser is used only to force ascii output
terser({
mangle: false,
compress: false,
format: {
comments: 'all',
beautify: true,
ascii_only: true,
indent_level: 2
}
})
]
},
{
file: 'dist/markdown-it.min.js',
format: 'umd',
name: 'markdownit',
plugins: [
terser({
format: {
ascii_only: true,
}
})
]
}
],
plugins: [
nodeResolve({ preferBuiltins: true }),
commonjs(),
json({ namedExports: false }),
nodePolyfills(),
{
banner() {
return `/*! ${pkg.name} ${pkg.version} https://github.com/${pkg.repository} @license ${pkg.license} */`;
}
}
]
};
Loading…
Cancel
Save