From 0181b70bc2c8f96f8c48399d3c31cd3ce13a5606 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Fri, 6 Nov 2020 23:55:30 +0100 Subject: [PATCH] add basic build script --- package.json | 11 ++++ packages/html/package.json | 5 ++ rollup.config.js | 66 ++++++++++++++++++++ yarn.lock | 124 ++++++++++++++++++++++++++++++++----- 4 files changed, 190 insertions(+), 16 deletions(-) create mode 100644 rollup.config.js diff --git a/package.json b/package.json index b9669d0f6..66ef13621 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ ], "scripts": { "start": "yarn --cwd ./docs start", + "build": "rollup -c --scope @tiptap/html", "build:docs": "yarn --cwd ./docs build", "build:packages": "yarn clean:packages && lerna exec -- microbundle --compress", "clean:packages": "rm -rf ./packages/*/dist", @@ -25,6 +26,12 @@ "@babel/plugin-proposal-nullish-coalescing-operator": "^7.10.4", "@babel/plugin-proposal-optional-chaining": "^7.11.0", "@babel/preset-env": "^7.11.5", + "@lerna/batch-packages": "^3.16.0", + "@lerna/filter-packages": "^3.18.0", + "@lerna/project": "^3.21.0", + "@rollup/plugin-babel": "^5.2.1", + "@rollup/plugin-commonjs": "^16.0.0", + "@rollup/plugin-node-resolve": "^10.0.0", "@types/prosemirror-commands": "^1.0.3", "@types/prosemirror-history": "^1.0.1", "@types/prosemirror-inputrules": "^1.0.3", @@ -45,6 +52,10 @@ "lerna": "^3.22.1", "levenary": "^1.1.1", "microbundle": "^0.12.4", + "minimist": "^1.2.5", + "rollup": "^2.33.1", + "rollup-plugin-terser": "^7.0.2", + "rollup-plugin-typescript2": "^0.29.0", "typedoc": "^0.19.2", "typescript": "^4.0.5", "vue": "^2.6.12" diff --git a/packages/html/package.json b/packages/html/package.json index ccc083e6a..e8455d14d 100644 --- a/packages/html/package.json +++ b/packages/html/package.json @@ -2,6 +2,11 @@ "name": "@tiptap/html", "version": "1.0.0", "source": "index.ts", + "main": "dist/tiptap-html.js", + "umd:main": "dist/tiptap-html.umd.js", + "module": "dist/tiptap-html.mjs", + "unpkg": "dist/tiptap-html.js", + "jsdelivr": "dist/tiptap-html.js", "files": [ "src", "dist" diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 000000000..5cffa9fa3 --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,66 @@ +import path from 'path' +import minimist from 'minimist' +import { getPackages } from '@lerna/project' +import filterPackages from '@lerna/filter-packages' +import batchPackages from '@lerna/batch-packages' +import typescript from 'rollup-plugin-typescript2' +import resolve from '@rollup/plugin-node-resolve' +import commonjs from '@rollup/plugin-commonjs' +import babel from '@rollup/plugin-babel' +import { terser } from 'rollup-plugin-terser' + +async function getSortedPackages(scope, ignore) { + const packages = await getPackages(__dirname) + const filtered = filterPackages(packages, scope, ignore, false) + + return batchPackages(filtered).reduce((arr, batch) => arr.concat(batch), []) +} + +async function main(commandLineArgs) { + const config = [] + // Support --scope and --ignore globs if passed in via commandline + const { scope, ignore } = minimist(process.argv.slice(2)) + const packages = await getSortedPackages(scope, ignore) + + // prevent rollup warning + delete commandLineArgs.scope + delete commandLineArgs.ignore + + packages.forEach(pkg => { + /* Absolute path to package directory */ + const basePath = path.relative(__dirname, pkg.location) + /* Absolute path to input file */ + const input = path.join(basePath, 'index.ts') + /* "main" field from package.json file. */ + const { main } = pkg.toJSON() + /* Push build config for this package. */ + + config.push({ + input, + output: [ + { + file: path.join(basePath, main), + format: 'cjs', + }, + ], + external: [ + ...Object.keys(pkg.dependencies || {}), + ...Object.keys(pkg.devDependencies || {}), + ...Object.keys(pkg.peerDependencies || {}), + ], + plugins: [ + resolve(), + commonjs(), + typescript(), + babel({ + babelHelpers: 'bundled', + }), + terser(), + ], + }) + }) + + return config +} + +export default main diff --git a/yarn.lock b/yarn.lock index 47f12d025..752a93957 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1263,6 +1263,14 @@ p-map "^2.1.0" semver "^6.2.0" +"@lerna/batch-packages@^3.16.0": + version "3.16.0" + resolved "https://registry.yarnpkg.com/@lerna/batch-packages/-/batch-packages-3.16.0.tgz#1c16cb697e7d718177db744cbcbdac4e30253c8c" + integrity sha512-7AdMkANpubY/FKFI01im01tlx6ygOBJ/0JcixMUWoWP/7Ds3SWQF22ID6fbBr38jUWptYLDs2fagtTDL7YUPuA== + dependencies: + "@lerna/package-graph" "3.16.0" + npmlog "^4.1.2" + "@lerna/bootstrap@3.21.0": version "3.21.0" resolved "https://registry.yarnpkg.com/@lerna/bootstrap/-/bootstrap-3.21.0.tgz#bcd1b651be5b0970b20d8fae04c864548123aed6" @@ -1473,7 +1481,7 @@ figgy-pudding "^3.5.1" npmlog "^4.1.2" -"@lerna/filter-packages@3.18.0": +"@lerna/filter-packages@3.18.0", "@lerna/filter-packages@^3.18.0": version "3.18.0" resolved "https://registry.yarnpkg.com/@lerna/filter-packages/-/filter-packages-3.18.0.tgz#6a7a376d285208db03a82958cfb8172e179b4e70" integrity sha512-6/0pMM04bCHNATIOkouuYmPg6KH3VkPCIgTfQmdkPJTullERyEQfNUKikrefjxo1vHOoCACDpy65JYyKiAbdwQ== @@ -1690,6 +1698,17 @@ tar "^4.4.10" temp-write "^3.4.0" +"@lerna/package-graph@3.16.0": + version "3.16.0" + resolved "https://registry.yarnpkg.com/@lerna/package-graph/-/package-graph-3.16.0.tgz#909c90fb41e02f2c19387342d2a5eefc36d56836" + integrity sha512-A2mum/gNbv7zCtAwJqoxzqv89As73OQNK2MgSX1SHWya46qoxO9a9Z2c5lOFQ8UFN5ZxqWMfFYXRCz7qzwmFXw== + dependencies: + "@lerna/prerelease-id-from-version" "3.16.0" + "@lerna/validation-error" "3.13.0" + npm-package-arg "^6.1.0" + npmlog "^4.1.2" + semver "^6.2.0" + "@lerna/package-graph@3.18.5": version "3.18.5" resolved "https://registry.yarnpkg.com/@lerna/package-graph/-/package-graph-3.18.5.tgz#c740e2ea3578d059e551633e950690831b941f6b" @@ -1727,7 +1746,7 @@ npmlog "^4.1.2" upath "^1.2.0" -"@lerna/project@3.21.0": +"@lerna/project@3.21.0", "@lerna/project@^3.21.0": version "3.21.0" resolved "https://registry.yarnpkg.com/@lerna/project/-/project-3.21.0.tgz#5d784d2d10c561a00f20320bcdb040997c10502d" integrity sha512-xT1mrpET2BF11CY32uypV2GPtPVm6Hgtha7D81GQP9iAitk9EccrdNjYGt5UBYASl4CIDXBRxwmTTVGfrCx82A== @@ -2087,7 +2106,7 @@ dependencies: slash "^3.0.0" -"@rollup/plugin-babel@^5.0.3": +"@rollup/plugin-babel@^5.0.3", "@rollup/plugin-babel@^5.2.1": version "5.2.1" resolved "https://registry.yarnpkg.com/@rollup/plugin-babel/-/plugin-babel-5.2.1.tgz#20fc8f8864dc0eaa1c5578408459606808f72924" integrity sha512-Jd7oqFR2dzZJ3NWANDyBjwTtX/lYbZpVcmkHrfQcpvawHs9E4c0nYk5U2mfZ6I/DZcIvy506KZJi54XK/jxH7A== @@ -2121,6 +2140,19 @@ magic-string "^0.25.7" resolve "^1.17.0" +"@rollup/plugin-commonjs@^16.0.0": + version "16.0.0" + resolved "https://registry.yarnpkg.com/@rollup/plugin-commonjs/-/plugin-commonjs-16.0.0.tgz#169004d56cd0f0a1d0f35915d31a036b0efe281f" + integrity sha512-LuNyypCP3msCGVQJ7ki8PqYdpjfEkE/xtFa5DqlF+7IBD0JsfMZ87C58heSwIMint58sAUZbt3ITqOmdQv/dXw== + dependencies: + "@rollup/pluginutils" "^3.1.0" + commondir "^1.0.1" + estree-walker "^2.0.1" + glob "^7.1.6" + is-reference "^1.2.1" + magic-string "^0.25.7" + resolve "^1.17.0" + "@rollup/plugin-json@^4.1.0": version "4.1.0" resolved "https://registry.yarnpkg.com/@rollup/plugin-json/-/plugin-json-4.1.0.tgz#54e09867ae6963c593844d8bd7a9c718294496f3" @@ -2128,6 +2160,18 @@ dependencies: "@rollup/pluginutils" "^3.0.8" +"@rollup/plugin-node-resolve@^10.0.0": + version "10.0.0" + resolved "https://registry.yarnpkg.com/@rollup/plugin-node-resolve/-/plugin-node-resolve-10.0.0.tgz#44064a2b98df7530e66acf8941ff262fc9b4ead8" + integrity sha512-sNijGta8fqzwA1VwUEtTvWCx2E7qC70NMsDh4ZG13byAXYigBNZMxALhKUSycBks5gupJdq0lFrKumFrRZ8H3A== + dependencies: + "@rollup/pluginutils" "^3.1.0" + "@types/resolve" "1.17.1" + builtin-modules "^3.1.0" + deepmerge "^4.2.2" + is-module "^1.0.0" + resolve "^1.17.0" + "@rollup/plugin-node-resolve@^6.1.0": version "6.1.0" resolved "https://registry.yarnpkg.com/@rollup/plugin-node-resolve/-/plugin-node-resolve-6.1.0.tgz#0d2909f4bf606ae34d43a9bc8be06a9b0c850cf0" @@ -4720,7 +4764,7 @@ css-what@2.1: resolved "https://registry.yarnpkg.com/css-what/-/css-what-2.1.3.tgz#a6d7604573365fe74686c3f311c56513d88285f2" integrity sha512-a+EPoD+uZiNfh+5fxw2nO9QwFa6nJe2Or35fGY6Ipw1R3R4AGz1d1TEZrCegvw2YTmZ0jXirGYlzxxpYSHwpEg== -css-what@^3.2.1, css-what@^3.4.2: +css-what@^3.2.1: version "3.4.2" resolved "https://registry.yarnpkg.com/css-what/-/css-what-3.4.2.tgz#ea7026fcb01777edbde52124e21f327e7ae950e4" integrity sha512-ACUm3L0/jiZTqfzRM3Hi9Q8eZqd6IK37mMWPLz9PJxkLWllYeRf+EHUSHYEtFop2Eqytaq1FizFVh7XfBnXCDQ== @@ -6295,7 +6339,7 @@ find-cache-dir@^2.0.0, find-cache-dir@^2.1.0: make-dir "^2.0.0" pkg-dir "^3.0.0" -find-cache-dir@^3.0.0: +find-cache-dir@^3.0.0, find-cache-dir@^3.3.1: version "3.3.1" resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-3.3.1.tgz#89b33fad4a4670daa94f855f7fbe31d6d84fe880" integrity sha512-t2GDMt3oGC/v+BMwzmllWDuJF/xcDtE5j/fCGbqDD7OLuJkj0cfh1YSA5VKPvwMeLFLNDBkwOKZ2X85jGLVftQ== @@ -7324,14 +7368,6 @@ hosted-git-info@^3.0.6: dependencies: lru-cache "^6.0.0" -hostic-dom@^0.8.5: - version "0.8.5" - resolved "https://registry.yarnpkg.com/hostic-dom/-/hostic-dom-0.8.5.tgz#500de796842454a745ce160d9cb0483c82643e28" - integrity sha512-0H5DTaE2/u3pSM5bPf7CaS9SunFASc0zlmw1R6hk0i6ozalRl0ePnAhm4YUYRG6pDbg0BYqCbjgwuFWOc3SskA== - dependencies: - css-what "^3.4.2" - he "^1.2.0" - hsl-regex@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/hsl-regex/-/hsl-regex-1.0.0.tgz#d49330c789ed819e276a4c0d272dffa30b18fe6e" @@ -8312,6 +8348,15 @@ jest-worker@^24.9.0: merge-stream "^2.0.0" supports-color "^6.1.0" +jest-worker@^26.2.1: + version "26.6.2" + resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-26.6.2.tgz#7f72cbc4d643c365e27b9fd775f9d0eaa9c7a8ed" + integrity sha512-KWYVV1c4i+jbMpaBC+U++4Va0cp8OisU185o73T1vo99hqi7w8tSJfUXYswwqqrjzwxa6KpRK54WhPvwf5w6PQ== + dependencies: + "@types/node" "*" + merge-stream "^2.0.0" + supports-color "^7.0.0" + js-base64@^2.1.8: version "2.6.4" resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-2.6.4.tgz#f4e686c5de1ea1f867dbcad3d46d969428df98c4" @@ -12007,6 +12052,13 @@ resolve@1.12.0: dependencies: path-parse "^1.0.6" +resolve@1.17.0: + version "1.17.0" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.17.0.tgz#b25941b54968231cc2d1bb76a79cb7f2c0bf8444" + integrity sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w== + dependencies: + path-parse "^1.0.6" + resolve@^1.1.6, resolve@^1.10.0, resolve@^1.11.0, resolve@^1.11.1, resolve@^1.12.0, resolve@^1.13.1, resolve@^1.16.0, resolve@^1.17.0, resolve@^1.2.0, resolve@^1.3.2, resolve@^1.8.1: version "1.18.1" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.18.1.tgz#018fcb2c5b207d2a6424aee361c5a266da8f4130" @@ -12138,6 +12190,16 @@ rollup-plugin-terser@^5.3.0: serialize-javascript "^4.0.0" terser "^4.6.2" +rollup-plugin-terser@^7.0.2: + version "7.0.2" + resolved "https://registry.yarnpkg.com/rollup-plugin-terser/-/rollup-plugin-terser-7.0.2.tgz#e8fbba4869981b2dc35ae7e8a502d5c6c04d324d" + integrity sha512-w3iIaU4OxcF52UUXiZNsNeuXIMDvFrr+ZXK6bFZ0Q60qyVfq4uLptoS4bbq3paG3x216eQllFZX7zt6TIImguQ== + dependencies: + "@babel/code-frame" "^7.10.4" + jest-worker "^26.2.1" + serialize-javascript "^4.0.0" + terser "^5.0.0" + rollup-plugin-typescript2@^0.25.3: version "0.25.3" resolved "https://registry.yarnpkg.com/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.25.3.tgz#a5fb2f0f85488789334ce540abe6c7011cbdf40f" @@ -12149,6 +12211,17 @@ rollup-plugin-typescript2@^0.25.3: rollup-pluginutils "2.8.1" tslib "1.10.0" +rollup-plugin-typescript2@^0.29.0: + version "0.29.0" + resolved "https://registry.yarnpkg.com/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.29.0.tgz#b7ad83f5241dbc5bdf1e98d9c3fca005ffe39e1a" + integrity sha512-YytahBSZCIjn/elFugEGQR5qTsVhxhUwGZIsA9TmrSsC88qroGo65O5HZP/TTArH2dm0vUmYWhKchhwi2wL9bw== + dependencies: + "@rollup/pluginutils" "^3.1.0" + find-cache-dir "^3.3.1" + fs-extra "8.1.0" + resolve "1.17.0" + tslib "2.0.1" + rollup-pluginutils@2.8.1: version "2.8.1" resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.8.1.tgz#8fa6dd0697344938ef26c2c09d2488ce9e33ce97" @@ -12172,7 +12245,7 @@ rollup@^1.32.1: "@types/node" "*" acorn "^7.1.0" -rollup@^2.26.11: +rollup@^2.26.11, rollup@^2.33.1: version "2.33.1" resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.33.1.tgz#802795164164ee63cd47769d8879c33ec8ae0c40" integrity sha512-uY4O/IoL9oNW8MMcbA5hcOaz6tZTMIh7qJHx/tzIJm+n1wLoY38BLn6fuy7DhR57oNFLMbDQtDeJoFURt5933w== @@ -12730,7 +12803,7 @@ source-map-resolve@^0.5.0: source-map-url "^0.4.0" urix "^0.1.0" -source-map-support@~0.5.12: +source-map-support@~0.5.12, source-map-support@~0.5.19: version "0.5.19" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61" integrity sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw== @@ -12765,6 +12838,11 @@ source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.0, source-map@~0.6.1: resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== +source-map@~0.7.2: + version "0.7.3" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383" + integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ== + sourcemap-codec@^1.4.4: version "1.4.8" resolved "https://registry.yarnpkg.com/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz#ea804bd94857402e6992d05a38ef1ae35a9ab4c4" @@ -13190,7 +13268,7 @@ supports-color@^6.1.0: dependencies: has-flag "^3.0.0" -supports-color@^7.1.0, supports-color@^7.2.0: +supports-color@^7.0.0, supports-color@^7.1.0, supports-color@^7.2.0: version "7.2.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== @@ -13359,6 +13437,15 @@ terser@^4.1.2, terser@^4.6.2, terser@^4.6.3: source-map "~0.6.1" source-map-support "~0.5.12" +terser@^5.0.0: + version "5.3.8" + resolved "https://registry.yarnpkg.com/terser/-/terser-5.3.8.tgz#991ae8ba21a3d990579b54aa9af11586197a75dd" + integrity sha512-zVotuHoIfnYjtlurOouTazciEfL7V38QMAOhGqpXDEg6yT13cF4+fEP9b0rrCEQTn+tT46uxgFsTZzhygk+CzQ== + dependencies: + commander "^2.20.0" + source-map "~0.7.2" + source-map-support "~0.5.19" + text-extensions@^1.0.0: version "1.9.0" resolved "https://registry.yarnpkg.com/text-extensions/-/text-extensions-1.9.0.tgz#1853e45fee39c945ce6f6c36b2d659b5aabc2a26" @@ -13617,6 +13704,11 @@ tslib@1.10.0: resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a" integrity sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ== +tslib@2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.0.1.tgz#410eb0d113e5b6356490eec749603725b021b43e" + integrity sha512-SgIkNheinmEBgx1IUNirK0TUD4X9yjjBRTqqjggWCU3pUEqIk3/Uwl3yRixYKT6WjQuGiwDv4NomL3wqRCj+CQ== + tslib@^1.10.0, tslib@^1.13.0, tslib@^1.8.1, tslib@^1.9.0: version "1.14.1" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"