Coder Social home page Coder Social logo

cheerego7 / slide-prefetch Goto Github PK

View Code? Open in Web Editor NEW

This project forked from netless-io/slide-prefetch

0.0 0.0 0.0 146 KB

Simple script to prefetch packed slide data on navigation.

License: MIT License

TypeScript 90.90% JavaScript 6.87% HTML 2.23%

slide-prefetch's Introduction

@netless/slide-prefetch

Simple script to prefetch packed slide data on navigation.

Usage

Additional Steps to Use it in Webpack 4

If you are using old bundlers which does not support new javascript syntax. You may encounter errors when use this library. Especially these two:

  • Logical OR Operator.

    // in ./src/utils.ts
    export function openCache(cacheName: string) {
      return (cachePromise ||= caches.open(cacheName));
    }
  • import.meta

    // in ./node_modules/@zip.js/zip.js/lib/core/codecs/codec-pool-worker.js
    workerData.worker = new Worker(new URL(workerData.scripts[0], import.meta.url));

While it is encouraged to use new bundlers (vite, webpack5, etc.), here is a workaround.

npm i -D \
  babel-loader @babel/core @babel/preset-env \
  @babel/plugin-proposal-logical-assignment-operators \
  @open-wc/webpack-import-meta-loader

webpack.config.js

{
  resolve: {
    extensions: ['js', '.mjs', 'ts', 'tsx']
  },
  module:{
    rules: [
      {
        test: /slide-prefetch\/dist\/index\.mjs$/,
        use: {
          loader: 'babel-loader',
          options: {
            presets: ['@babel/preset-env'],
            plugins: ['@babel/plugin-proposal-logical-assignment-operators']
          }
        }
      },
      {
        test: /@zip\.js\/zip\.js\/lib\/core\/codecs\/codec-pool-worker\.js$/,
        use: {
          loader: '@open-wc/webpack-import-meta-loader'
        }
      }
    }
  }
}

Develop

npm run build
npm run test:web
npm run test:electron

License

The MIT License.

slide-prefetch's People

Contributors

hyrious avatar

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.