Skip to content

Commit

Permalink
Adds rollup cleanup plugin to remove code comments from build folder
Browse files Browse the repository at this point in the history
  • Loading branch information
tsov committed Sep 28, 2023
1 parent be0ab54 commit 724742d
Show file tree
Hide file tree
Showing 13 changed files with 85 additions and 28 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,27 +60,27 @@ or via CDN
Sortable,
Droppable,
Swappable,
} from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/index.js';
} from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/index.mjs';
</script>
<!-- Draggable only -->
<script type="module">
import Draggable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Draggable/Draggable.js';
import Draggable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Draggable/Draggable.mjs';
</script>
<!-- Sortable only -->
<script type="module">
import Sortable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Sortable/Sortable.js';
import Sortable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Sortable/Sortable.mjs';
</script>
<!-- Droppable only -->
<script type="module">
import Droppable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Droppable/Droppable.js';
import Droppable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Droppable/Droppable.mjs';
</script>
<!-- Swappable only -->
<script type="module">
import Swappable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Swappable/Swappable.js';
import Swappable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Swappable/Swappable.mjs';
</script>
<!-- Plugins only -->
<script type="module">
import * as Plugins from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Plugins/index.js';
import * as Plugins from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Plugins/index.mjs';
</script>
<!-- UMD browser -->
<script src="https://cdn.jsdelivr.net/npm/@shopify/draggable/build/umd/index.min.js"></script>
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
"drag-and-drop",
"es6"
],
"main": "build/cjs/index.js",
"module": "build/esm/index.js",
"esnext": "build/esnext/index.esnext",
"main": "build/cjs/index.cjs",
"module": "build/esm/index.mjs",
"esnext": "build/esnext/index.mjs",
"umd": "build/umd/index.js",
"types": "./index.d.ts",
"scripts": {
Expand Down Expand Up @@ -68,6 +68,7 @@
"jest-environment-jsdom": "^29.7.0",
"prettier": "^3.0.3",
"rollup": "^3.29.3",
"rollup-plugin-cleanup": "^3.2.1",
"rollup-plugin-includepaths": "^0.2.4",
"rollup-plugin-node-externals": "^6.1.1",
"timers": "^0.1.1",
Expand Down
15 changes: 10 additions & 5 deletions rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {babel, RollupBabelInputPluginOptions} from '@rollup/plugin-babel';
import commonjs from '@rollup/plugin-commonjs';
import {nodeResolve} from '@rollup/plugin-node-resolve';
import includePaths from 'rollup-plugin-includepaths';
import cleanupPlugin from 'rollup-plugin-cleanup';

const packageJSON = readFileSync(
new URL('./package.json', import.meta.url).pathname,
Expand All @@ -29,9 +30,9 @@ export function generateConfig({
shared: 'src/shared',
},
paths: ['src/'],
extensions: ['.js', '.ts'],
extensions: [...extensions],
}),
nodeResolve({extensions}),
nodeResolve({extensions: [...extensions]}),
commonjs(),
babel({
extensions,
Expand All @@ -40,6 +41,10 @@ export function generateConfig({
envName: 'production',
targets,
}),
cleanupPlugin({
extensions: [...extensions],
maxEmptyLines: 1,
}),
],
output,
};
Expand All @@ -53,14 +58,14 @@ const config = [
format: 'cjs',
dir: path.dirname(pkg.main),
preserveModules: true,
entryFileNames: '[name].js',
entryFileNames: '[name].cjs',
exports: 'named',
},
{
format: 'esm',
dir: path.dirname(pkg.module),
preserveModules: true,
entryFileNames: '[name].js',
entryFileNames: '[name].mjs',
},
{
format: 'umd',
Expand All @@ -76,7 +81,7 @@ const config = [
format: 'esm',
dir: path.dirname(pkg.esnext),
preserveModules: true,
entryFileNames: '[name].esnext',
entryFileNames: '[name].mjs',
},
],
}),
Expand Down
2 changes: 1 addition & 1 deletion src/Draggable/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const draggable = new Draggable(document.querySelectorAll('ul'), {

```html
<script type="module">
import Draggable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Draggable/Draggable.js';
import Draggable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Draggable/Draggable.mjs';
const draggable = new Draggable(document.querySelectorAll('ul'), {
draggable: 'li',
Expand Down
2 changes: 1 addition & 1 deletion src/Droppable/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const droppable = new Droppable(document.querySelectorAll('.container'), {

```html
<script type="module">
import Droppable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Droppable/Droppable.js';
import Droppable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Droppable/Droppable.mjs';
const droppable = new Droppable(document.querySelectorAll('.container'), {
draggable: '.item',
Expand Down
4 changes: 2 additions & 2 deletions src/Plugins/Collidable/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ const draggable = new Draggable(document.querySelectorAll('ul'), {

```html
<script type="module">
import Draggable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Draggable/Draggable.js';
import Collidable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Plugins/Collidable.js';
import Draggable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Draggable/Draggable.mjs';
import Collidable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Plugins/Collidable.mjs';
const draggable = new Draggable(document.querySelectorAll('ul'), {
draggable: 'li',
Expand Down
4 changes: 2 additions & 2 deletions src/Plugins/ResizeMirror/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ const draggable = new Draggable(document.querySelectorAll('ul'), {

```html
<script type="module">
import Draggable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Draggable/Draggable.js';
import ResizeMirror from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Plugins/ResizeMirror.js';
import Draggable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Draggable/Draggable.mjs';
import ResizeMirror from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Plugins/ResizeMirror.mjs';
const draggable = new Draggable(document.querySelectorAll('ul'), {
draggable: 'li',
Expand Down
4 changes: 2 additions & 2 deletions src/Plugins/Snappable/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ const draggable = new Draggable(document.querySelectorAll('ul'), {

```html
<script type="module">
import Draggable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Draggable/Draggable.js';
import Snappable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Plugins/Snappable.js';
import Draggable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Draggable/Draggable.mjs';
import Snappable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Plugins/Snappable.mjs';
const draggable = new Draggable(document.querySelectorAll('ul'), {
draggable: 'li',
Expand Down
4 changes: 2 additions & 2 deletions src/Plugins/SortAnimation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ const sortable = new Sortable(document.querySelectorAll('ul'), {

```html
<script type="module">
import Sortable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Sortable/Sortable.js';
import Snappable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Plugins/Snappable.js';
import Sortable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Sortable/Sortable.mjs';
import Snappable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Plugins/Snappable.mjs';
const sortable = new Sortable(document.querySelectorAll('ul'), {
draggable: 'li',
Expand Down
4 changes: 2 additions & 2 deletions src/Plugins/SwapAnimation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ const sortable = new Sortable(document.querySelectorAll('ul'), {

```html
<script type="module">
import Sortable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Sortable/Sortable.js';
import SwapAnimation from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Plugins/SwapAnimation.js';
import Sortable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Sortable/Sortable.mjs';
import SwapAnimation from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Plugins/SwapAnimation.mjs';
const sortable = new Sortable(document.querySelectorAll('ul'), {
draggable: 'li',
Expand Down
2 changes: 1 addition & 1 deletion src/Sortable/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const sortable = new Sortable(document.querySelectorAll('ul'), {

```html
<script type="module">
import Sortable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Sortable/Sortable.js';
import Sortable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Sortable/Sortable.mjs';
const sortable = new Sortable(document.querySelectorAll('ul'), {
draggable: 'li',
Expand Down
2 changes: 1 addition & 1 deletion src/Swappable/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const swappable = new Swappable(document.querySelectorAll('ul'), {

```html
<script type="module">
import Swappable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Swappable/Swappable.js';
import Swappable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Swappable/Swappable.mjs';
const swappable = new Swappable(document.querySelectorAll('ul'), {
draggable: 'li',
Expand Down
51 changes: 51 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3775,6 +3775,11 @@ estraverse@^5.1.0, estraverse@^5.2.0, estraverse@^5.3.0:
resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.3.0.tgz#2eea5290702f26ab8fe5370370ff86c965d21123"
integrity sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==

estree-walker@^0.6.1:
version "0.6.1"
resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-0.6.1.tgz#53049143f40c6eb918b23671d1fe3219f3a1b362"
integrity sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==

estree-walker@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-2.0.2.tgz#52f010178c2a4c117a7757cfe942adb7d2da4cac"
Expand Down Expand Up @@ -5172,6 +5177,15 @@ jest@^29.7.0:
import-local "^3.0.2"
jest-cli "^29.7.0"

js-cleanup@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/js-cleanup/-/js-cleanup-1.2.0.tgz#8dbc65954b1d38b255f1e8cf02cd17b3f7a053f9"
integrity sha512-JeDD0yiiSt80fXzAVa/crrS0JDPQljyBG/RpOtaSbyDq03VHa9szJWMaWOYU/bcTn412uMN2MxApXq8v79cUiQ==
dependencies:
magic-string "^0.25.7"
perf-regexes "^1.0.1"
skip-regex "^1.0.2"

"js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
Expand Down Expand Up @@ -5563,6 +5577,13 @@ lru-cache@^6.0.0:
dependencies:
yallist "^4.0.0"

magic-string@^0.25.7:
version "0.25.9"
resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.9.tgz#de7f9faf91ef8a1c91d02c2e5314c8277dbcdd1c"
integrity sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==
dependencies:
sourcemap-codec "^1.4.8"

magic-string@^0.27.0:
version "0.27.0"
resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.27.0.tgz#e4a3413b4bab6d98d2becffd48b4a257effdbbf3"
Expand Down Expand Up @@ -6080,6 +6101,11 @@ path-type@^4.0.0:
resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b"
integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==

perf-regexes@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/perf-regexes/-/perf-regexes-1.0.1.tgz#6da1d62f5a94bf9353a0451bccacf69068b75d0b"
integrity sha512-L7MXxUDtqr4PUaLFCDCXBfGV/6KLIuSEccizDI7JxT+c9x1G1v04BQ4+4oag84SHaCdrBgQAIs/Cqn+flwFPng==

performance-now@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
Expand Down Expand Up @@ -6488,6 +6514,14 @@ rimraf@^3.0.2:
dependencies:
glob "^7.1.3"

rollup-plugin-cleanup@^3.2.1:
version "3.2.1"
resolved "https://registry.yarnpkg.com/rollup-plugin-cleanup/-/rollup-plugin-cleanup-3.2.1.tgz#8cbc92ecf58babd7c210051929797f137bbf777c"
integrity sha512-zuv8EhoO3TpnrU8MX8W7YxSbO4gmOR0ny06Lm3nkFfq0IVKdBUtHwhVzY1OAJyNCIAdLiyPnOrU0KnO0Fri1GQ==
dependencies:
js-cleanup "^1.2.0"
rollup-pluginutils "^2.8.2"

rollup-plugin-includepaths@^0.2.4:
version "0.2.4"
resolved "https://registry.yarnpkg.com/rollup-plugin-includepaths/-/rollup-plugin-includepaths-0.2.4.tgz#eb21d2d05ad410856a7c2f0612a85983fd11cc62"
Expand All @@ -6498,6 +6532,13 @@ rollup-plugin-node-externals@^6.1.1:
resolved "https://registry.yarnpkg.com/rollup-plugin-node-externals/-/rollup-plugin-node-externals-6.1.1.tgz#dff1a85073fe3c0b2c423b280259fe80392026a8"
integrity sha512-127OFMkpH5rBVlRHRBDUMk1m1sGuzbGy7so5aj/IkpUb2r3+wOWjR/erUzd2ChEQWPsxsyQG6xpYYvPBAdcBRA==

rollup-pluginutils@^2.8.2:
version "2.8.2"
resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz#72f2af0748b592364dbd3389e600e5a9444a351e"
integrity sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ==
dependencies:
estree-walker "^0.6.1"

rollup@^3.29.3:
version "3.29.3"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-3.29.3.tgz#97769774ccaa6a3059083d4680fcabd8ead01289"
Expand Down Expand Up @@ -6648,6 +6689,11 @@ sisteransi@^1.0.5:
resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.5.tgz#134d681297756437cc05ca01370d3a7a571075ed"
integrity sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==

skip-regex@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/skip-regex/-/skip-regex-1.0.2.tgz#ac655d77e7c771ac2b9f37585fea37bff56ad65b"
integrity sha512-pEjMUbwJ5Pl/6Vn6FsamXHXItJXSRftcibixDmNCWbWhic0hzHrwkMZo0IZ7fMRH9KxcWDFSkzhccB4285PutA==

slash@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634"
Expand Down Expand Up @@ -6691,6 +6737,11 @@ source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1:
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==

sourcemap-codec@^1.4.8:
version "1.4.8"
resolved "https://registry.yarnpkg.com/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz#ea804bd94857402e6992d05a38ef1ae35a9ab4c4"
integrity sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==

spawn-command@^0.0.2-1:
version "0.0.2-1"
resolved "https://registry.yarnpkg.com/spawn-command/-/spawn-command-0.0.2-1.tgz#62f5e9466981c1b796dc5929937e11c9c6921bd0"
Expand Down

0 comments on commit 724742d

Please sign in to comment.