Skip to content

Commit 6d7f81f

Browse files
Export the Splide class itself instead of a global function.
1 parent dc41356 commit 6d7f81f

File tree

6 files changed

+601
-788
lines changed

6 files changed

+601
-788
lines changed

build/complete/complete.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,18 @@
55
* @copyright Naotoshi Fujita. All rights reserved.
66
*/
77

8-
import Splide from '../../src/js/splide';
8+
import { default as Core } from '../../src/js/splide';
99
import { COMPLETE } from '../../src/js/components';
1010

1111

1212
/**
13-
* Create and return a new Splide instance.
14-
*
15-
* @param {Element|string} root - A root element or a selector for it.
16-
* @param {Object} options - Optional. Options overwriting defaults.
17-
*
18-
* @return {Splide} - A Splide instance.
13+
* Export Splide with all components.
1914
*/
20-
export default function splide( root, options = {} ) {
21-
return new Splide( root, options, COMPLETE );
15+
export class Splide extends Core {
16+
constructor( root, options ) {
17+
super( root, options, COMPLETE );
18+
}
2219
}
2320

24-
// Register the function above as global for non-ES6 environment.
25-
window.splide = splide;
21+
// Register the class as a global variable for non-ES6 environment.
22+
window.Splide = Splide;

build/complete/config.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ const webpack = require( 'webpack' );
44
module.exports = {
55
entry: './build/complete/complete.js',
66
output: {
7-
filename : 'splide.js',
8-
library : 'Splide',
9-
libraryTarget: 'umd',
7+
filename: 'splide.js',
108
},
119
module: {
1210
rules: [

dist/js/splide.min.js

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/splide.min.js.gz

-42 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)