Skip to content

Commit

Permalink
browserify => rollup.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitaly Puzrin committed Oct 13, 2020
1 parent cb42dad commit a2cf20d
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 18 deletions.
1 change: 1 addition & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ ignorePatterns:
- node_modules
- support/demo_template/sample.js
- benchmark/extra/
- rollup.config.js

rules:
accessor-pairs: 2
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
13 changes: 2 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand All @@ -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",
Expand All @@ -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
Expand Down
5 changes: 1 addition & 4 deletions support/build_demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 44 additions & 0 deletions support/demo_template/rollup.config.js
Original file line number Diff line number Diff line change
@@ -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 changes: 53 additions & 0 deletions support/rollup.config.js
Original file line number Diff line number Diff line change
@@ -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} */`;
}
}
]
};

0 comments on commit a2cf20d

Please sign in to comment.