Skip to content

Commit 2bc3799

Browse files
authored
Merge pull request #582 from Shopify/rollup-cleanup
Rollup cleanup
2 parents be0ab54 + 762ffbf commit 2bc3799

File tree

14 files changed

+172
-36
lines changed

14 files changed

+172
-36
lines changed

.changeset/late-nails-matter.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@shopify/draggable': patch
3+
---
4+
5+
- Cleans up code comments from build folder
6+
- Also resolves absolute paths for ts build declarations
7+
- Renames build files with .cjs and .mjs

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,27 +60,27 @@ or via CDN
6060
Sortable,
6161
Droppable,
6262
Swappable,
63-
} from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/index.js';
63+
} from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/index.mjs';
6464
</script>
6565
<!-- Draggable only -->
6666
<script type="module">
67-
import Draggable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Draggable/Draggable.js';
67+
import Draggable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Draggable/Draggable.mjs';
6868
</script>
6969
<!-- Sortable only -->
7070
<script type="module">
71-
import Sortable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Sortable/Sortable.js';
71+
import Sortable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Sortable/Sortable.mjs';
7272
</script>
7373
<!-- Droppable only -->
7474
<script type="module">
75-
import Droppable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Droppable/Droppable.js';
75+
import Droppable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Droppable/Droppable.mjs';
7676
</script>
7777
<!-- Swappable only -->
7878
<script type="module">
79-
import Swappable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Swappable/Swappable.js';
79+
import Swappable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Swappable/Swappable.mjs';
8080
</script>
8181
<!-- Plugins only -->
8282
<script type="module">
83-
import * as Plugins from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Plugins/index.js';
83+
import * as Plugins from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Plugins/index.mjs';
8484
</script>
8585
<!-- UMD browser -->
8686
<script src="https://cdn.jsdelivr.net/npm/@shopify/draggable/build/umd/index.min.js"></script>

package.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
"drag-and-drop",
2323
"es6"
2424
],
25-
"main": "build/cjs/index.js",
26-
"module": "build/esm/index.js",
27-
"esnext": "build/esnext/index.esnext",
25+
"main": "build/cjs/index.cjs",
26+
"module": "build/esm/index.mjs",
27+
"esnext": "build/esnext/index.mjs",
2828
"umd": "build/umd/index.js",
2929
"types": "./index.d.ts",
3030
"scripts": {
@@ -37,11 +37,14 @@
3737
"esdoc": "esdoc -c esdoc.json",
3838
"test": "jest",
3939
"build:development": "yarn rollup --config rollup.development.config.ts --configPlugin @rollup/plugin-typescript",
40-
"build:production": "tsc && yarn rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript && yarn uglifyjs --compress --mangle -- build/umd/index.js -o build/umd/index.min.js",
40+
"build:production": "tsc && tsc-alias && yarn rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript && yarn uglifyjs --compress --mangle -- build/umd/index.js -o build/umd/index.min.js",
4141
"verify": "yarn lint && yarn type-check && yarn build && yarn test"
4242
},
4343
"files": [
4444
"build/**/*",
45+
"!build/ts/**/*.tsbuildinfo",
46+
"!build/ts/**/tests/",
47+
"!build/ts/**/test/",
4548
"index.d.ts"
4649
],
4750
"devDependencies": {
@@ -68,9 +71,11 @@
6871
"jest-environment-jsdom": "^29.7.0",
6972
"prettier": "^3.0.3",
7073
"rollup": "^3.29.3",
74+
"rollup-plugin-cleanup": "^3.2.1",
7175
"rollup-plugin-includepaths": "^0.2.4",
7276
"rollup-plugin-node-externals": "^6.1.1",
7377
"timers": "^0.1.1",
78+
"tsc-alias": "^1.8.8",
7479
"typescript": "^5.2.2",
7580
"uglify-js": "^3.17.4"
7681
},

rollup.config.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {babel, RollupBabelInputPluginOptions} from '@rollup/plugin-babel';
66
import commonjs from '@rollup/plugin-commonjs';
77
import {nodeResolve} from '@rollup/plugin-node-resolve';
88
import includePaths from 'rollup-plugin-includepaths';
9+
import cleanupPlugin from 'rollup-plugin-cleanup';
910

1011
const packageJSON = readFileSync(
1112
new URL('./package.json', import.meta.url).pathname,
@@ -29,9 +30,9 @@ export function generateConfig({
2930
shared: 'src/shared',
3031
},
3132
paths: ['src/'],
32-
extensions: ['.js', '.ts'],
33+
extensions: [...extensions],
3334
}),
34-
nodeResolve({extensions}),
35+
nodeResolve({extensions: [...extensions]}),
3536
commonjs(),
3637
babel({
3738
extensions,
@@ -40,6 +41,10 @@ export function generateConfig({
4041
envName: 'production',
4142
targets,
4243
}),
44+
cleanupPlugin({
45+
extensions: [...extensions],
46+
maxEmptyLines: 1,
47+
}),
4348
],
4449
output,
4550
};
@@ -53,14 +58,14 @@ const config = [
5358
format: 'cjs',
5459
dir: path.dirname(pkg.main),
5560
preserveModules: true,
56-
entryFileNames: '[name].js',
61+
entryFileNames: '[name].cjs',
5762
exports: 'named',
5863
},
5964
{
6065
format: 'esm',
6166
dir: path.dirname(pkg.module),
6267
preserveModules: true,
63-
entryFileNames: '[name].js',
68+
entryFileNames: '[name].mjs',
6469
},
6570
{
6671
format: 'umd',
@@ -76,7 +81,7 @@ const config = [
7681
format: 'esm',
7782
dir: path.dirname(pkg.esnext),
7883
preserveModules: true,
79-
entryFileNames: '[name].esnext',
84+
entryFileNames: '[name].mjs',
8085
},
8186
],
8287
}),

src/Draggable/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const draggable = new Draggable(document.querySelectorAll('ul'), {
1818

1919
```html
2020
<script type="module">
21-
import Draggable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Draggable/Draggable.js';
21+
import Draggable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Draggable/Draggable.mjs';
2222
2323
const draggable = new Draggable(document.querySelectorAll('ul'), {
2424
draggable: 'li',

src/Droppable/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const droppable = new Droppable(document.querySelectorAll('.container'), {
2424

2525
```html
2626
<script type="module">
27-
import Droppable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Droppable/Droppable.js';
27+
import Droppable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Droppable/Droppable.mjs';
2828
2929
const droppable = new Droppable(document.querySelectorAll('.container'), {
3030
draggable: '.item',

src/Plugins/Collidable/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ const draggable = new Draggable(document.querySelectorAll('ul'), {
2626

2727
```html
2828
<script type="module">
29-
import Draggable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Draggable/Draggable.js';
30-
import Collidable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Plugins/Collidable.js';
29+
import Draggable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Draggable/Draggable.mjs';
30+
import Collidable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Plugins/Collidable.mjs';
3131
3232
const draggable = new Draggable(document.querySelectorAll('ul'), {
3333
draggable: 'li',

src/Plugins/ResizeMirror/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ const draggable = new Draggable(document.querySelectorAll('ul'), {
3131

3232
```html
3333
<script type="module">
34-
import Draggable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Draggable/Draggable.js';
35-
import ResizeMirror from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Plugins/ResizeMirror.js';
34+
import Draggable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Draggable/Draggable.mjs';
35+
import ResizeMirror from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Plugins/ResizeMirror.mjs';
3636
3737
const draggable = new Draggable(document.querySelectorAll('ul'), {
3838
draggable: 'li',

src/Plugins/Snappable/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ const draggable = new Draggable(document.querySelectorAll('ul'), {
2525

2626
```html
2727
<script type="module">
28-
import Draggable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Draggable/Draggable.js';
29-
import Snappable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Plugins/Snappable.js';
28+
import Draggable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Draggable/Draggable.mjs';
29+
import Snappable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Plugins/Snappable.mjs';
3030
3131
const draggable = new Draggable(document.querySelectorAll('ul'), {
3232
draggable: 'li',

src/Plugins/SortAnimation/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ const sortable = new Sortable(document.querySelectorAll('ul'), {
3434

3535
```html
3636
<script type="module">
37-
import Sortable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Sortable/Sortable.js';
38-
import Snappable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Plugins/Snappable.js';
37+
import Sortable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Sortable/Sortable.mjs';
38+
import Snappable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Plugins/Snappable.mjs';
3939
4040
const sortable = new Sortable(document.querySelectorAll('ul'), {
4141
draggable: 'li',

0 commit comments

Comments
 (0)