diff --git a/.eslintignore b/.eslintignore index 5cf02fcc8..8e442399b 100644 --- a/.eslintignore +++ b/.eslintignore @@ -4,3 +4,4 @@ dist/ node_modules support/demo_template/sample.js benchmark/extra/ +rollup.config.js diff --git a/.gitignore b/.gitignore index b02f491fb..c3ced4727 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ coverage/ demo/ apidoc/ *.log +*.mjs diff --git a/package.json b/package.json index bba9ebfd1..204f43a59 100644 --- a/package.json +++ b/package.json @@ -12,14 +12,19 @@ "repository": "markdown-it/markdown-it", "license": "MIT", "main": "index.js", + "module": "index.mjs", "bin": { "markdown-it": "bin/markdown-it.js" }, "scripts": { - "test": "make test" + "build": "rollup -c", + "prepare": "npm run build", + "test": "make test", + "watch": "rollup -c -w" }, "files": [ "index.js", + "index.mjs", "bin/", "lib/", "dist/" @@ -56,6 +61,10 @@ "mocha": "^6.1.4", "ndoc": "^5.0.0", "pug-cli": "^1.0.0-alpha6", + "rollup": "^1.26.3", + "rollup-plugin-commonjs": "^10.1.0", + "rollup-plugin-json": "^4.0.0", + "rollup-plugin-node-resolve": "^5.2.0", "stylus": "^0.54.5", "supertest": "^4.0.2", "terser": "^4.1.2" diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 000000000..84f6bd1ca --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,18 @@ +import commonjs from 'rollup-plugin-commonjs'; +import nodeResolve from 'rollup-plugin-node-resolve'; +import json from 'rollup-plugin-json'; + +export default { + input: 'index.js', + output: { + file: 'index.mjs', + format: 'esm' + }, + plugins: [ + json(), + nodeResolve({ + preferBuiltins: false + }), + commonjs() + ] +};