Skip to content
This repository has been archived by the owner on Apr 21, 2022. It is now read-only.

Small CommonJS wrapper which handles issues like `TypeError: $ is undefined` thrown by the owlCarousel2 plugin bundled with `browserify`, `webpack` or other bundlers

License

Notifications You must be signed in to change notification settings

cpoftea/owl.carousel-module

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

owlCarousel2 is a jQuery plugin written in an IIFE pattern.

Plugin initialization relies on jQuery in global object.

Most users face an issue like TypeError: $ is undefined thrown by the plugin bundled with browserify, webpack or other bundlers, because jQuery isn't attached to the global object by default in a module execution context. It makes users to expose jQuery to global object what can be harmful - overwriting another version of jQuery which the rest of the code relies on.

Here's a small CommonJS wrapper which handles this issue.

It preserves existing jQuery, then exposes our jQuery, initializes owlCarousel2, and, in the end, exposes preserved jQuery back (if there was one before).

Installation

Install peer dependencies

npm i jquery@^3
npm i owl.carousel@^2

Install module

npm i git://github.com/cpof-tea/owl.carousel-module#semver:^1

Usage

import $ from 'jquery';
import 'owl.carousel-module';

$('.owl-carousel').owlCarousel({ ... });

About

Small CommonJS wrapper which handles issues like `TypeError: $ is undefined` thrown by the owlCarousel2 plugin bundled with `browserify`, `webpack` or other bundlers

Topics

Resources

License

Stars

Watchers

Forks