zepto-webpack
raw JSON → 1.2.1 verified Sat Apr 25 auth: no javascript deprecated
A Webpack-compatible repackaging of Zepto 1.2.0 that exports the library as a module for use with Webpack's ProvidePlugin. This package modifies Zepto's source to include `module.exports = window.Zepto`, allowing direct `$` usage via ProvidePlugin. It addresses Ajax issues (issue 921) and is intended for projects using Webpack 1–4. Released under MIT. Last updated in 2016; no active maintenance or updates beyond Zepto 1.2.0.
Common errors
error Module not found: Error: Can't resolve 'zepto-webpack' ↓
cause Package not installed or not in node_modules.
fix
Run
npm install zepto-webpack and ensure webpack config resolves to node_modules. error $ is not defined ↓
cause ProvidePlugin not configured correctly or zepto-webpack fails to assign to $.
fix
Add
new webpack.ProvidePlugin({ $: 'zepto-webpack' }) to webpack plugins array. error Uncaught TypeError: Cannot read property 'fn' of undefined ↓
cause Zepto not loaded properly (likely due to wrong import method).
fix
Use ProvidePlugin as described, not direct import/require.
error window.Zepto is not a function ↓
cause The package may not have executed because Webpack tree-shaking removed it.
fix
Ensure ProvidePlugin is used and that zepto-webpack is included in the bundle (e.g., avoid unused module warnings).
Warnings
deprecated This package is based on Zepto 1.2.0 (2016) and is no longer maintained. Use a modern jQuery alternative or a direct Zepto ESM wrapper. ↓
fix Consider using Zepto via CDN or a maintained npm package like 'zepto' with proper module bundler config.
gotcha Direct import or require may not work correctly because the package only adds `module.exports = window.Zepto` at the end. It does not export Zepto as a proper ES module. ↓
fix Always use ProvidePlugin as shown in the README. Do not rely on standard module imports.
gotcha If used with Webpack 5, ProvidePlugin behavior may differ. The package may not correctly set up Zepto globally. ↓
fix Test with Webpack 5; consider patching the package manually or switching to a maintained alternative.
breaking The package modifies Zepto source to add `module.exports = window.Zepto`. This overwrites any previous exports and may conflict with other Zepto wrappers. ↓
fix Use only one Zepto wrapper; avoid mixing with other Zepto modules.
Install
npm install zepto-webpack yarn add zepto-webpack pnpm add zepto-webpack Imports
- $ wrong
import $ from 'zepto-webpack'correctnew webpack.ProvidePlugin({ $: 'zepto-webpack' }) - Zepto wrong
const Zepto = require('zepto-webpack')correctnew webpack.ProvidePlugin({ Zepto: 'zepto-webpack' }) - Module
// Not applicable; use ProvidePlugin
Quickstart
// webpack.config.js
const webpack = require('webpack');
module.exports = {
entry: './src/index.js',
output: { path: __dirname + '/dist', filename: 'bundle.js' },
plugins: [
new webpack.ProvidePlugin({
$: 'zepto-webpack',
Zepto: 'zepto-webpack'
})
]
};