Skip to content

Commit 1549dd3

Browse files
committed
Fix 'make dist'.
* Use rollup uglify plugin to create minified dist. * Fix Makefile code to insert license text. * Move dev dependencies to proper place in package.json. .
1 parent 52c25d7 commit 1549dd3

File tree

6 files changed

+142
-21
lines changed

6 files changed

+142
-21
lines changed

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ BENCHINP?=bench/samples/README.md
44
VERSION?=$(SPECVERSION)
55
JSMODULES=$(wildcard lib/*.js)
66
UGLIFYJS=node_modules/.bin/uglifyjs
7+
LICENSETEXT="/* commonmark $(VERSION) https://github.com/commonmark/commonmark.js @license BSD3 */"
78

89
.PHONY: dingus dist test bench bench-detailed npm lint clean update-spec
910

@@ -13,12 +14,11 @@ lint:
1314
dist: dist/commonmark.js dist/commonmark.min.js
1415

1516
dist/commonmark.js: lib/index.js ${JSMODULES}
16-
echo '/* commonmark $(VERSION) https://github.com/CommonMark/commonmark.js @license BSD3 */' > $@
17-
npm run build >> $@
17+
npm run build
18+
(echo $(LICENSETEXT) && cat $@) > $@.tmp && mv $@.tmp $@
1819

1920
dist/commonmark.min.js: dist/commonmark.js
20-
$(UGLIFYJS) --version # version should be at least 2.5.0
21-
$(UGLIFYJS) $< --compress keep_fargs=true,pure_getters=true --comments > $@
21+
(echo $(LICENSETEXT) && cat $@) > $@.tmp && mv $@.tmp $@
2222

2323
update-spec:
2424
curl 'https://raw.githubusercontent.com/jgm/CommonMark/master/spec.txt' > $(SPEC)

dist/commonmark.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* commonmark 0.29 https://github.com/commonmark/commonmark.js @license BSD3 */
12
(function (global, factory) {
23
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
34
typeof define === 'function' && define.amd ? define(['exports'], factory) :

dist/commonmark.min.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 119 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,8 @@
3333
"test": "node ./test/test"
3434
},
3535
"dependencies": {
36-
"@rollup/plugin-commonjs": "^11.0.1",
37-
"@rollup/plugin-node-resolve": "^7.0.0",
3836
"entities": "~1.1.1",
3937
"mdurl": "~1.0.1",
40-
"minimist": "~1.2.0",
41-
"rollup": "^1.29.0",
4238
"string.prototype.repeat": "^0.2.0"
4339
},
4440
"directories": {
@@ -48,7 +44,12 @@
4844
"node": "*"
4945
},
5046
"devDependencies": {
47+
"@rollup/plugin-commonjs": "^11.0.1",
48+
"@rollup/plugin-node-resolve": "^7.0.0",
49+
"rollup-plugin-uglify": "^6.0.4",
5150
"@rollup/plugin-json": "^4.0.1",
51+
"rollup": "^1.29.0",
52+
"minimist": "~1.2.0",
5253
"benchmark": "^2.1.4",
5354
"bower": "^1.8.8",
5455
"cached-path-relative": "^1.0.2",

rollup.config.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,22 @@
22
import nodeResolve from "@rollup/plugin-node-resolve";
33
import commonjs from "@rollup/plugin-commonjs";
44
import json from "@rollup/plugin-json";
5+
import { uglify } from "rollup-plugin-uglify";
56

67
export default {
78
input: "lib/index.js",
8-
output: {
9+
output: [
10+
{
911
file: "dist/commonmark.js",
1012
format: "umd",
1113
name: "commonmark"
12-
},
14+
},
15+
{
16+
file: "dist/commonmark.min.js",
17+
format: "umd",
18+
name: "commonmark",
19+
plugins: [uglify()]
20+
}
21+
],
1322
plugins: [nodeResolve(), commonjs(), json()]
1423
};

0 commit comments

Comments
 (0)