|
| 1 | +npmbin=./node_modules/.bin |
| 2 | +esbuild=$(npmbin)/esbuild |
| 3 | +eslint=$(npmbin)/eslint |
| 4 | +tsc=$(npmbin)/tsc |
| 5 | +nyc=$(npmbin)/nyc |
| 6 | + |
| 7 | +commonopts=--outfile=$@ --log-level=warning --bundle |
| 8 | +sourcemaps=--sourcemap --sourcemap=external |
| 9 | +nodeopts=--format=cjs --platform=node |
| 10 | +browseropts=--format=iife $(sourcemaps) |
| 11 | +moduleopts=--format=esm $(sourcemaps) |
| 12 | + |
| 13 | +lintany=--cache |
| 14 | +lintjs=$(lintany) --ext=.js --ignore-pattern=test/typings.js lib test |
| 15 | +lintts=$(lintany) --ext=.ts --cache-location .tslintcache -c .tslintrc.yml dist test |
| 16 | + |
| 17 | +prepare :: |
| 18 | + @echo "> $@" |
| 19 | + @pnpm i ‑‑frozen‑lockfile --no-verify-store-integrity |
| 20 | + |
| 21 | +all: dist/index.mjs dist/index.min.mjs dist/index.cjs.js \ |
| 22 | + dist/index.iife.js dist/index.iife.min.js \ |
| 23 | + dist/detached-browser.mjs dist/detached-browser.min.mjs dist/detached-browser.cjs.js \ |
| 24 | + dist/detached-browser.iife.js dist/detached-browser.iife.min.js \ |
| 25 | + dist/detach-window.mjs dist/detach-window.min.mjs dist/detach-window.cjs.js \ |
| 26 | + dist/detach-window.iife.js dist/detach-window.iife.min.js \ |
| 27 | + dist/detach-backbone.mjs dist/detach-backbone.min.mjs dist/detach-backbone.cjs.js \ |
| 28 | + dist/detach-backbone.iife.js dist/detach-backbone.iife.min.js |
| 29 | + |
| 30 | +lint :: |
| 31 | + @echo "> $@" |
| 32 | + @$(eslint) $(lintjs) |
| 33 | + @$(eslint) $(lintts) |
| 34 | + |
| 35 | +fix :: |
| 36 | + @echo "> $@" |
| 37 | + @$(eslint) --fix $(lintjs) |
| 38 | + @$(eslint) --fix $(lintts) |
| 39 | + |
| 40 | +all-test :: all test/typings.js |
| 41 | + |
| 42 | +test :: all-test |
| 43 | + @echo "> $@" |
| 44 | + @node -r esm test/detached-browser |
| 45 | + @node -r esm test/detach-window |
| 46 | + @node -r esm test/detach-backbone |
| 47 | + @node -r esm test/typings |
| 48 | + |
| 49 | +coverage :: all-test |
| 50 | + @echo "> $@" |
| 51 | + @$(nyc) -c -s node -r esm test/detached-browser |
| 52 | + @$(nyc) -c -s --no-clean node -r esm test/detach-window |
| 53 | + @$(nyc) -c -s --no-clean node -r esm test/detach-backbone |
| 54 | + @$(nyc) report |
| 55 | + @$(nyc) check-coverage |
| 56 | + |
| 57 | +clean :: |
| 58 | + @echo "> $@" |
| 59 | + @rm -f dist/*.js dist/*.mjs dist/*.map test/typings.js |
| 60 | + |
| 61 | +new :: clean fix coverage |
| 62 | + |
| 63 | +upgrade :: |
| 64 | + @echo "> $@" |
| 65 | + @cp package.json package.json.orig |
| 66 | + @ncu -u |
| 67 | + @diff -q package.json package.json.orig && rm package.json.orig \ |
| 68 | + || (rm package.json.orig && pnpm i && make new) |
| 69 | + |
| 70 | +dist/index.mjs: lib/index.js lib/detached-browser.js lib/event-emitter.js \ |
| 71 | + lib/detach-window.js lib/detach-backbone.js |
| 72 | + @echo "> $@" |
| 73 | + @$(esbuild) $(commonopts) $(moduleopts) $< |
| 74 | + |
| 75 | +dist/index.min.mjs: lib/index.js lib/detached-browser.js lib/event-emitter.js \ |
| 76 | + lib/detach-window.js lib/detach-backbone.js |
| 77 | + @echo "> $@" |
| 78 | + @$(esbuild) $(commonopts) $(moduleopts) --minify $< |
| 79 | + |
| 80 | +dist/index.cjs.js: lib/index.js lib/detached-browser.js lib/event-emitter.js \ |
| 81 | + lib/detach-window.js lib/detach-backbone.js |
| 82 | + @echo "> $@" |
| 83 | + @$(esbuild) $(commonopts) $(nodeopts) $< |
| 84 | + |
| 85 | +dist/index.iife.js: lib/index.js lib/detached-browser.js lib/event-emitter.js \ |
| 86 | + lib/detach-window.js lib/detach-backbone.js |
| 87 | + @echo "> $@" |
| 88 | + @$(esbuild) $(commonopts) $(browseropts) --name=detachedNavigation $< |
| 89 | + |
| 90 | +dist/index.iife.min.js: lib/index.js lib/detached-browser.js lib/event-emitter.js \ |
| 91 | + lib/detach-window.js lib/detach-backbone.js |
| 92 | + @echo "> $@" |
| 93 | + @$(esbuild) $(commonopts) $(browseropts) --minify --name=detachedNavigation $< |
| 94 | + |
| 95 | +dist/detached-browser.mjs: lib/detached-browser.js lib/event-emitter.js |
| 96 | + @echo "> $@" |
| 97 | + @$(esbuild) $(commonopts) $(moduleopts) $< |
| 98 | + |
| 99 | +dist/detached-browser.min.mjs: lib/detached-browser.js lib/event-emitter.js |
| 100 | + @echo "> $@" |
| 101 | + @$(esbuild) $(commonopts) $(moduleopts) --minify $< |
| 102 | + |
| 103 | +dist/detached-browser.cjs.js: lib/detached-browser.js lib/event-emitter.js |
| 104 | + @echo "> $@" |
| 105 | + @$(esbuild) $(commonopts) $(nodeopts) $< |
| 106 | + |
| 107 | +dist/detached-browser.iife.js: lib/detached-browser.js lib/event-emitter.js |
| 108 | + @echo "> $@" |
| 109 | + @$(esbuild) $(commonopts) $(browseropts) --name=createDetachedBrowser $< |
| 110 | + |
| 111 | +dist/detached-browser.iife.min.js: lib/detached-browser.js lib/event-emitter.js |
| 112 | + @echo "> $@" |
| 113 | + @$(esbuild) $(commonopts) $(browseropts) --minify --name=createDetachedBrowser $< |
| 114 | + |
| 115 | +dist/detach-window.mjs: lib/detach-window.js |
| 116 | + @echo "> $@" |
| 117 | + @$(esbuild) $(commonopts) $(moduleopts) $< |
| 118 | + |
| 119 | +dist/detach-window.min.mjs: lib/detach-window.js |
| 120 | + @echo "> $@" |
| 121 | + @$(esbuild) $(commonopts) $(moduleopts) --minify $< |
| 122 | + |
| 123 | +dist/detach-window.cjs.js: lib/detach-window.js |
| 124 | + @echo "> $@" |
| 125 | + @$(esbuild) $(commonopts) $(nodeopts) $< |
| 126 | + |
| 127 | +dist/detach-window.iife.js: lib/detach-window.js |
| 128 | + @echo "> $@" |
| 129 | + @$(esbuild) $(commonopts) $(browseropts) --name=detachWindowHistory $< |
| 130 | + |
| 131 | +dist/detach-window.iife.min.js: lib/detach-window.js |
| 132 | + @echo "> $@" |
| 133 | + @$(esbuild) $(commonopts) $(browseropts) --minify --name=detachWindowHistory $< |
| 134 | + |
| 135 | +dist/detach-backbone.mjs: lib/detach-backbone.js |
| 136 | + @echo "> $@" |
| 137 | + @$(esbuild) $(commonopts) $(moduleopts) $< |
| 138 | + |
| 139 | +dist/detach-backbone.min.mjs: lib/detach-backbone.js |
| 140 | + @echo "> $@" |
| 141 | + @$(esbuild) $(commonopts) $(moduleopts) --minify $< |
| 142 | + |
| 143 | +dist/detach-backbone.cjs.js: lib/detach-backbone.js |
| 144 | + @echo "> $@" |
| 145 | + @$(esbuild) $(commonopts) $(nodeopts) $< |
| 146 | + |
| 147 | +dist/detach-backbone.iife.js: lib/detach-backbone.js |
| 148 | + @echo "> $@" |
| 149 | + @$(esbuild) $(commonopts) $(browseropts) --name=detachBackboneHistory $< |
| 150 | + |
| 151 | +dist/detach-backbone.iife.min.js: lib/detach-backbone.js |
| 152 | + @echo "> $@" |
| 153 | + @$(esbuild) $(commonopts) $(browseropts) --minify --name=detachBackboneHistory $< |
| 154 | + |
| 155 | +test/typings.js: test/typings.ts |
| 156 | + @echo "> $@" |
| 157 | + @$(tsc) --target es2015 $< |
0 commit comments