Coder Social home page Coder Social logo

plugin's Introduction

Swup Base Plugin

Base class for creating swup plugins.

Creating a Plugin

To create a new plugin, use the official swup plugin template. It comes with detailed instructions and the required tooling.

Usage

Import the base class and extend your plugin from it.

import Plugin from '@swup/plugin';

export default class PluginName extends Plugin {
  name = 'PluginName';
  mount() {}
  unmount() {}
}

Development

The official swup command-line interface has commands to help with bundling and linting plugins.

npm install --save-dev @swup/cli

Bundling

Bundle the plugin for production using microbundle, creating ESM and UMD builds.

# Bundle and transpile plugin code for distribution
swup package:bundle

# Bundle plugin code in watch mode
swup package:dev

Linting & formatting

Lint the plugin code using prettier and swup's recommended rules.

# Lint plugin code
swup package:lint

# Fix and format any lint errors
swup package:format

Package info

Check that the plugin's package.json file contains the required information for microbundle: input, output, export map, amd name, etc.

# Check plugin package info
swup package:check

plugin's People

Contributors

daun avatar dependabot[bot] avatar gmrchk avatar hirasso avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

plugin's Issues

Extract build CLI from base plugin to avoid bundling build dependencies

I recently got snagged including all of TypeScript as part of a front-end package because @swup/plugin has microbundle as a dependency. It looks like microbundle is used for building assets, rather than as a internal dependency used within src/. So, I think its safe to switch it over :)

`swup-plugin lint` only lints `js` files

Description of the issue

swup-plugin lint should also lint .ts, .mjs, .cjs files.

How to reproduce the issue

Run swup-plugin lint in a Plugin built in TypeScript

Add a way of requiring a minimum swup version

  • Optionally let plugins define which version of swup they need to run
  • Mostly useful for the v3 switch since there's a few incompatibilities
  • Alternative: Stick with feature detection like if (typeof swup.someFunction === 'function') { }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.