From cf84e67756534ac3d2c71a98635e29a6cb3edfc8 Mon Sep 17 00:00:00 2001 From: barrelltech <99540338+barrelltech@users.noreply.github.com> Date: Tue, 16 Apr 2024 11:00:30 +0200 Subject: [PATCH] Add umd distribution (#84) * Add umd distribution * add UMD exports * 3.5.5 --------- Co-authored-by: ishiko --- .github/workflows/pr-test.yml | 5 +++++ package.json | 3 ++- rollup.config.ts | 24 +++++++++++++++++++++++- src/fsrs/default.ts | 2 +- 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr-test.yml b/.github/workflows/pr-test.yml index feb620e..b83c4f0 100644 --- a/.github/workflows/pr-test.yml +++ b/.github/workflows/pr-test.yml @@ -5,6 +5,11 @@ on: branches: - master +permissions: + contents: write + checks: write + pull-requests: write + jobs: test: runs-on: ubuntu-latest diff --git a/package.json b/package.json index 0d9a0f2..926e4ab 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,9 @@ { "name": "ts-fsrs", - "version": "3.5.4", + "version": "3.5.5", "description": "ts-fsrs is a ES modules package based on TypeScript, used to implement the Free Spaced Repetition Scheduler (FSRS) algorithm. It helps developers apply FSRS to their flashcard applications, there by improving the user learning experience.", "main": "dist/index.cjs", + "umd": "dist/index.umd.js", "module": "dist/index.mjs", "types": "dist/index.d.ts", "keywords": [ diff --git a/rollup.config.ts b/rollup.config.ts index fa39138..fa14f35 100644 --- a/rollup.config.ts +++ b/rollup.config.ts @@ -41,6 +41,28 @@ export default defineConfig([ commonjs(), ], external: ["seedrandom"], + }, + { + input: 'src/fsrs/index.ts', + output: { + file: 'dist/index.umd.js', + format: 'umd', + name: 'FSRS', + sourcemap: true, + globals: { + seedrandom: 'seedrandom', + }, + }, + plugins: [ + resolve(), + esbuild({ + target: 'es2017', + minify: true, + sourceMap: true, + }), + commonjs(), + ], + external: ["seedrandom"], }, { input: 'src/fsrs/index.ts', @@ -57,4 +79,4 @@ export default defineConfig([ ], external: ["seedrandom"], }, -]); \ No newline at end of file +]); diff --git a/src/fsrs/default.ts b/src/fsrs/default.ts index 35bfe54..a4c3f3d 100644 --- a/src/fsrs/default.ts +++ b/src/fsrs/default.ts @@ -9,7 +9,7 @@ export const default_w = [ ]; export const default_enable_fuzz = false; -export const FSRSVersion: string = "3.5.4"; +export const FSRSVersion: string = "3.5.5"; export const generatorParameters = ( props?: Partial,