Skip to content

Commit b81e8f6

Browse files
committed
Convert build to rollup
1 parent 16c3172 commit b81e8f6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+706
-1365
lines changed

.changeset/smart-cycles-raise.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/draggable': minor
3+
---
4+
5+
Converted build from webpack to rollout. Import paths have changed

.github/ISSUE_TEMPLATE.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ _Please remember that with sample code it's easier to reproduce the bug and it's
1616

1717
### 4. Please tell us about your environment:
1818

19-
* **Library version:** [1.0.0-beta.X | v1 stable | etc...]
20-
* **Browsers:** [all | Chrome vX | Firefox vX | Safari vX | Edge vX | iOS vX | Android vX | etc...]
21-
* **Tech stack:** [all | TypeScript vX | ES6/7 | ES5 | React | etc...]
22-
* **Other information:** [Detailed explanation | Stacktraces | Related issues | Suggestions how to fix | Links for us to have context | etc...]
19+
- **Library version:** [1.X.X | v1 stable | etc...]
20+
- **Browsers:** [all | Chrome vX | Firefox vX | Safari vX | Edge vX | iOS vX | Android vX | etc...]
21+
- **Tech stack:** [all | TypeScript vX | ES6/7 | ES5 | React | etc...]
22+
- **Other information:** [Detailed explanation | Stacktraces | Related issues | Suggestions how to fix | Links for us to have context | etc...]

.github/PULL_REQUEST_TEMPLATE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- Thank you for submitting a pull request! Please make sure you have read the [contribution guidelines](https://github.com/Shopify/draggable/blob/master/CONTRIBUTING.md) before proceeding. -->
1+
<!-- Thank you for submitting a pull request! Please make sure you have read the [contribution guidelines](https://github.com/Shopify/draggable/blob/main/CONTRIBUTING.md) before proceeding. -->
22

33
### This PR implements or fixes...
44

.github/workflows/ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ jobs:
2828
- name: Library typecheck
2929
run: yarn type-check
3030

31-
- name: Scripts typecheck
32-
run: yarn type-check:scripts
31+
- name: Build
32+
run: yarn build
3333

3434
- name: Test
3535
run: yarn test

.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ example.html
1717

1818
coverage/
1919
docs/
20-
lib/
21-
coverage/
20+
build/
21+
.rollup.cache/
2222

2323
# 'cause we are all yarny and stuff
2424
package-lock.json

.vscode/settings.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
"files.exclude": {
33
"**/.git": true,
44
"**/.DS_Store": true,
5-
"**/node_modules": true,
6-
"lib": true
5+
"**/node_modules": true
76
},
87
"search.exclude": {
98
"**/node_modules": true,
10-
"lib": true
9+
"build": true
1110
},
1211
"[typescript]": {
1312
"editor.formatOnSave": false,

CONTRIBUTING.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ appreciated and encouraged.
1414

1515
## Code of Conduct
1616

17-
This project and everyone participating in it is governed by the [Code of Conduct document](https://github.com/Shopify/draggable/blob/master/CODE_OF_CONDUCT.md).
17+
This project and everyone participating in it is governed by the [Code of Conduct document](https://github.com/Shopify/draggable/blob/main/CODE_OF_CONDUCT.md).
1818
By participating, you are expected to uphold this code. Please report unacceptable behaviour to [email protected] or [email protected].
1919

2020
## How to contribute
@@ -29,11 +29,11 @@ please open a new issue with labels: `bug`, `documentation`, `feature-request` o
2929
Pull requests are more than welcome! Just make sure that to include a description of the problem and how you are attempting to fix the issue, or
3030
simply follow the Pull Request description template.
3131

32-
We also require Pull Requests to sync with master via rebase (not merge). So when you need to sync up your branch with master use: `git pull --rebase origin master`,
32+
We also require Pull Requests to sync with main via rebase (not merge). So when you need to sync up your branch with main use: `git pull --rebase origin main`,
3333
or if you need to sync up with another branch `git pull --rebase origin some-other-branch-name`. Doing so will remove of an extra merge commit in the git history.
3434
This will also require a force push to the branch, e.g. `git push -u origin +some-branch`. The `+` in the last command indicates that you are force pushing changes.
3535

36-
Additionally we require commits to be atomic and squashed where needed. This will keep the git history clean on master. To squash commits use the `git rebase -i @~2`
36+
Additionally we require commits to be atomic and squashed where needed. This will keep the git history clean on main. To squash commits use the `git rebase -i @~2`
3737
command to do an interactive rebase. This will allow you to merge multiple commits into one. To read up more on this please visit: [Git Tools Rewriting History](https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History)
3838

3939
### JS Docblocks

README.md

+41-44
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
[![npm version](https://badge.fury.io/js/%40shopify%2Fdraggable.svg)](https://badge.fury.io/js/%40shopify%2Fdraggable)
2-
[![codecov](https://codecov.io/gh/Shopify/draggable/branch/master/graph/badge.svg)](https://codecov.io/gh/Shopify/draggable)
3-
[![Greenkeeper badge](https://badges.greenkeeper.io/Shopify/draggable.svg)](https://greenkeeper.io/)
1+
[![npm version](https://img.shields.io/npm/v/@shopify/draggable.svg?label=@shopify/draggable)](https://www.npmjs.com/package/@shopify/draggable) [![CI](https://github.com/shopify/draggable/workflows/CI/badge.svg)](https://github.com/Shopify/draggable/actions?query=branch%3Amain) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/Shopify/draggable/blob/main/CONTRIBUTING.md) ![Bundle size](https://img.shields.io/badge/Bundle%20size-16.2kB-red.svg)
42

53
<a href="https://shopify.github.io/draggable" title="Visit Draggable website">
64
<img src="https://user-images.githubusercontent.com/643944/35602291-99e2c56e-0605-11e8-847f-95f1f6be1610.jpg" alt="">
@@ -40,59 +38,64 @@ interface, for more information read the documentation below.
4038

4139
## Install
4240

43-
**NOTE**: When installing with npm or yarn, `@shopify/[email protected]` will be installed by default. If you want to install the latest version, please install `@shopify/[email protected]` or `@shopify/draggable@next`.
44-
4541
You can install the library via npm.
4642

47-
```
43+
```bash
4844
npm install @shopify/draggable --save
4945
```
5046

5147
or via yarn:
5248

53-
```
49+
```bash
5450
yarn add @shopify/draggable
5551
```
5652

5753
or via CDN
5854

5955
```html
6056
<!-- Entire bundle -->
61-
<script src="https://cdn.jsdelivr.net/npm/@shopify/[email protected]/lib/draggable.bundle.js"></script>
62-
<!-- legacy bundle for older browsers (IE11) -->
63-
<script src="https://cdn.jsdelivr.net/npm/@shopify/[email protected]/lib/draggable.bundle.legacy.js"></script>
57+
<script type="module">
58+
import {
59+
Draggable,
60+
Sortable,
61+
Droppable,
62+
Swappable,
63+
} from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/index.js';
64+
</script>
6465
<!-- Draggable only -->
65-
<script src="https://cdn.jsdelivr.net/npm/@shopify/[email protected]/lib/draggable.js"></script>
66+
<script type="module">
67+
import Draggable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Draggable/Draggable.js';
68+
</script>
6669
<!-- Sortable only -->
67-
<script src="https://cdn.jsdelivr.net/npm/@shopify/[email protected]/lib/sortable.js"></script>
70+
<script type="module">
71+
import Sortable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Sortable/Sortable.js';
72+
</script>
6873
<!-- Droppable only -->
69-
<script src="https://cdn.jsdelivr.net/npm/@shopify/[email protected]/lib/droppable.js"></script>
74+
<script type="module">
75+
import Droppable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Droppable/Droppable.js';
76+
</script>
7077
<!-- Swappable only -->
71-
<script src="https://cdn.jsdelivr.net/npm/@shopify/[email protected]/lib/swappable.js"></script>
78+
<script type="module">
79+
import Swappable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Swappable/Swappable.js';
80+
</script>
7281
<!-- Plugins only -->
73-
<script src="https://cdn.jsdelivr.net/npm/@shopify/[email protected]/lib/plugins.js"></script>
82+
<script type="module">
83+
import * as Plugins from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Plugins/index.js';
84+
</script>
85+
<!-- UMD browser -->
86+
<script src="https://cdn.jsdelivr.net/npm/@shopify/draggable/build/umd/index.min.js"></script>
87+
<script>
88+
console.log(window.Draggable);
89+
</script>
7490
```
7591

7692
## Browser Compatibility
7793

78-
| ![Chrome](https://raw.github.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png) | ![Firefox](https://raw.github.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png) | ![IE](https://raw.github.com/alrra/browser-logos/master/src/archive/internet-explorer_9-11/internet-explorer_9-11_48x48.png) | ![Opera](https://raw.github.com/alrra/browser-logos/master/src/opera/opera_48x48.png) | ![Safari](https://raw.github.com/alrra/browser-logos/master/src/safari/safari_48x48.png) | ![Edge](https://raw.github.com/alrra/browser-logos/master/src/edge/edge_48x48.png) |
79-
| ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
80-
| Latest ✔ | Latest ✔ | 11+ ✔ | Latest ✔ | Latest ✔ | Latest ✔ |
81-
82-
## Bundle sizes
83-
84-
| Package name | ES6 bundle sizes | ES5 bundle sizes |
85-
| -------------------------- | ---------------- | ---------------- |
86-
| draggable.bundle.js | ~11kb | ~19.2kb |
87-
| draggable.bundle.legacy.js | ~19.2kb | ~25.63kb |
88-
| draggable.js | ~8.06kb | ~15.36kb |
89-
| sortable.js | ~8.93kb | ~16.51kb |
90-
| swappable.js | ~8.56kb | ~16.14kb |
91-
| droppable.js | ~8.8kb | ~16.55kb |
92-
| plugins.js | ~2.37kb | ~8.76kb |
93-
| plugins/collidable.js | ~1.45kb | ~7.81kb |
94-
| plugins/snappable.js | ~1.19kb | ~6.94kb |
95-
| plugins/swap-animation.js | ~1kb | ~6.65kb |
94+
Check the "browserlist" property in [package.json](https://github.com/Shopify/draggable/blob/main/package.json#L88) for more info
95+
96+
| ![Chrome](https://raw.github.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png) | ![Firefox](https://raw.github.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png) | ![Opera](https://raw.github.com/alrra/browser-logos/master/src/opera/opera_48x48.png) | ![Safari](https://raw.github.com/alrra/browser-logos/master/src/safari/safari_48x48.png) | ![Edge](https://raw.github.com/alrra/browser-logos/master/src/edge/edge_48x48.png) |
97+
| ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
98+
| Last 3 versions ✔ | Last 3 versions ✔ | Last 3 versions ✔ | Last 3 versions ✔ | Last 3 versions ✔ |
9699

97100
## Documentation
98101

@@ -121,15 +124,13 @@ You can find the documentation for each module within their respective directori
121124
- [ResizeMirror](src/Plugins/ResizeMirror)
122125
- [Snappable](src/Plugins/Snappable)
123126
- [SwapAnimation](src/Plugins/SwapAnimation)
124-
- [SortAnimation](src/Plugins/SortAnimation) (Added in: v1.0.0-beta.10)
127+
- [SortAnimation](src/Plugins/SortAnimation)
125128
- [Sortable](src/Sortable)
126129
- [SortableEvent](src/Sortable/SortableEvent)
127130
- [Swappable](src/Swappable)
128131
- [SwappableEvent](src/Swappable/SwappableEvent)
129132

130-
## TypeScript
131-
132-
(Added in: v1.0.0-beta.9)
133+
### TypeScript
133134

134135
Draggable includes [TypeScript](http://typescriptlang.org) definitions.
135136

@@ -139,7 +140,7 @@ Draggable includes [TypeScript](http://typescriptlang.org) definitions.
139140

140141
To run the `examples` project locally, simply run the following from the `draggable` root:
141142

142-
```
143+
```bash
143144
yarn && yarn start
144145
```
145146

@@ -150,11 +151,7 @@ changes from both `src/` and `examples/src` and reloads the browser.
150151

151152
Contributions are more than welcome, the code base is still new and needs more love.
152153

153-
For more information, please checkout the [contributing document](https://github.com/Shopify/draggable/blob/master/CONTRIBUTING.md).
154-
155-
## Roadmap
156-
157-
We are currently working on `v1.0.0-beta.12`. Check out the [project board](https://github.com/Shopify/draggable/projects/3) to see tasks and follow progress on the release. Any Pull Requests should be pointed against the feature branch `v1.0.0-beta.12`.
154+
For more information, please checkout the [contributing document](https://github.com/Shopify/draggable/blob/main/CONTRIBUTING.md).
158155

159156
## Related resources
160157

@@ -163,4 +160,4 @@ We are currently working on `v1.0.0-beta.12`. Check out the [project board](http
163160

164161
## Copyright
165162

166-
Copyright (c) 2018 Shopify. See LICENSE.md for further details.
163+
Copyright (c) 2018-present Shopify. See LICENSE.md for further details.

babel.config.js

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* @type {import('@babel/core').TransformOptions}
3+
*/
4+
module.exports = function (api) {
5+
api.cache(true);
6+
7+
return {
8+
presets: [
9+
[
10+
'@babel/preset-env',
11+
{useBuiltIns: 'entry', corejs: '3.0', bugfixes: true},
12+
],
13+
['@babel/preset-typescript'],
14+
],
15+
assumptions: {
16+
setPublicClassFields: true,
17+
privateFieldsAsProperties: true,
18+
// nothing accesses `document.all`:
19+
noDocumentAll: true,
20+
// nothing relies on class constructors invoked without `new` throwing:
21+
noClassCalls: true,
22+
// nothing should be relying on tagged template strings being frozen:
23+
mutableTemplateObject: true,
24+
// nothing is relying on Function.prototype.length:
25+
ignoreFunctionLength: true,
26+
// nothing is relying on mutable re-exported bindings:
27+
constantReexports: true,
28+
// don't bother marking Module records non-enumerable:
29+
enumerableModuleMeta: true,
30+
// nothing uses [[Symbol.toPrimitive]]:
31+
// (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toPrimitive)
32+
ignoreToPrimitiveHint: true,
33+
// nothing relies on spread copying Symbol keys: ({...{ [Symbol()]: 1 }})
34+
objectRestNoSymbols: true,
35+
// nothing relies on `new (() => {})` throwing:
36+
noNewArrows: true,
37+
// transpile object spread to assignment instead of defineProperty():
38+
setSpreadProperties: true,
39+
// nothing should be using custom iterator protocol:
40+
skipForOfIteratorClosing: true,
41+
// nothing inherits from a constructor function with explicit return value:
42+
superIsCallableConstructor: true,
43+
// nothing relies on CJS-transpiled namespace imports having all properties prior to module execution completing:
44+
noIncompleteNsImportDetection: true,
45+
},
46+
};
47+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
declare module 'rollup-plugin-includepaths' {
2+
interface Options {
3+
include: {[key: string]: string};
4+
paths: string[];
5+
extensions: string[];
6+
}
7+
export = includePaths;
8+
function includePaths(object: Options);
9+
}

examples/src/components/PageHeader/PageHeader.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
<header class="PageHeader">
77
<h1 class="Heading Heading--size1">{{ ViewAttr.parent }}</h1>
88
<h2 class="Subheading">{{ ViewAttr.subheading }}</h2>
9-
<a href="https://github.com/Shopify/draggable/tree/master/examples/src/content/{{ contentPath }}" class="Link Link--typeUnderlined" title="See this code example">View code on GitHub</a>
9+
<a href="https://github.com/Shopify/draggable/tree/main/examples/src/content/{{ contentPath }}" class="Link Link--typeUnderlined" title="See this code example">View code on GitHub</a>
1010
</header>
1111
{% endmacro %}

examples/src/components/Sidebar/Sidebar.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<footer class="SidebarFooter">
1212
<p class="LegalText"><a href="https://shopify.github.io/draggable/" class="Link Link--typeDark" title="Visit Draggable JS">draggable.js</a> was developed by <a href="https://github.com/tsov" class="Link Link--noWrap" title="Github: tsov">Max Hoffmann</a> and <a href="https://github.com/beefchimi" class="Link Link--noWrap" title="Github: beefchimi">Curtis Dulmage</a>.</p>
1313

14-
<p class="LegalText">Draggable is released under the <a href="https://github.com/Shopify/shopify.github.com/blob/master/LICENSE.md" class="Link Link--noWrap" title="View MIT License" target="_blank" rel="noopener">MIT license</a>. You are free to use the code from this library for both personal and commercial use.</p>
14+
<p class="LegalText">Draggable is released under the <a href="https://github.com/Shopify/shopify.github.com/blob/main/LICENSE.md" class="Link Link--noWrap" title="View MIT License" target="_blank" rel="noopener">MIT license</a>. You are free to use the code from this library for both personal and commercial use.</p>
1515

1616
<p class="preload-cursors"><b>Special thanks</b> <u>to all of our</u> <a href="https://github.com/Shopify/draggable/graphs/contributors" title="We love our contributors!">amazing contributors</a>.</p>
1717
</footer>

0 commit comments

Comments
 (0)