diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0e23c1cbf..06bb6cb94 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,7 +22,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v3 with: - node-version: '20' + node-version: 'latest' - name: Install dependencies run: npm ci - name: Build diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index af777f01c..bb79c5ae5 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -12,7 +12,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v3 with: - node-version: '22' + node-version: 'latest' - name: Install dependencies run: npm ci - name: Test diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index b1d09df01..decaf2873 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -12,7 +12,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v3 with: - node-version: '20' + node-version: 'latest' - name: Build run: | npm ci diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 23b031950..5c9f7ecc2 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -12,7 +12,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v3 with: - node-version: '20' + node-version: 'latest' - name: Install dependencies run: npm ci - name: Lint diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml index aeee66c7e..2c7bbb34d 100644 --- a/.github/workflows/performance.yml +++ b/.github/workflows/performance.yml @@ -17,7 +17,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v3 with: - node-version: '20' + node-version: 'latest' - name: Download artifacts uses: actions/download-artifact@v4 with: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index eaf5f7613..242bf0181 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,20 +7,10 @@ jobs: matrix: os: [ubuntu-latest] timezone: [Etc/GMT, Asia/Shanghai, America/New_York] - node-version: [22] + node-version: [latest] include: - - os: macos-latest - timezone: America/New_York - node-versoin: 22 - os: ubuntu-latest - timezone: Etc/GMT - node-version: 20 - - os: ubuntu-latest - timezone: Asia/Shanghai - node-version: 18 - - os: ubuntu-latest - timezone: Asia/Shanghai - node-version: 16 + node-version: lts/* runs-on: ${{ matrix.os }} steps: - name: Checkout @@ -39,7 +29,7 @@ jobs: name: dist-${{ matrix.os }} path: dist - name: Run Test - run: TZ=${{ matrix.timezone }} npm test + run: TZ=${{ matrix.timezone || 'Etc/GMT' }} npm test - name: Archive npm failure logs uses: actions/upload-artifact@v4 if: failure() @@ -57,7 +47,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v3 with: - node-version: 22 + node-version: latest - name: Download artifacts uses: actions/download-artifact@v4 with: diff --git a/package-lock.json b/package-lock.json index c9f33eabd..3a1411e4c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -64,7 +64,7 @@ "typescript": "^4.5.3" }, "engines": { - "node": ">=16" + "node": ">=20" }, "funding": { "type": "opencollective", diff --git a/package.json b/package.json index 2a4358709..b5d52b5be 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ }, "types": "dist/index.d.ts", "engines": { - "node": ">=16" + "node": ">=20" }, "scripts": { "lint": "eslint \"**/*.mjs\" \"**/*.ts\" .", diff --git a/rollup.config.mjs b/rollup.config.mjs index ca7261f10..1aacef3ea 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -89,7 +89,7 @@ const nodeEsm = { plugins: [ versionInjection, replace(esmRequire), - typescript(tsconfig('es6')) + typescript(tsconfig('ES2020')) ], treeshake, input @@ -108,7 +108,7 @@ const browserEsm = { replace(browserBase64), replace(browserCrypto), replace(browserStream), - typescript(tsconfig('es6')) + typescript(tsconfig('ES2020')) ], treeshake, input @@ -128,7 +128,7 @@ const browserUmd = { replace(browserBase64), replace(browserCrypto), replace(browserStream), - typescript(tsconfig('es5')) + typescript(tsconfig('ES2020')) ], treeshake, input @@ -148,7 +148,7 @@ const browserMin = { replace(browserBase64), replace(browserCrypto), replace(browserStream), - typescript(tsconfig('es5')), + typescript(tsconfig('ES2020')), uglify() ], treeshake, diff --git a/src/build/base64-impl-browser.spec.ts b/src/build/base64-impl-browser.spec.ts index 6078d0c3b..499ef37b4 100644 --- a/src/build/base64-impl-browser.spec.ts +++ b/src/build/base64-impl-browser.spec.ts @@ -2,11 +2,6 @@ import * as base64 from './base64-impl-browser' import { JSDOM } from 'jsdom' describe('base64-impl/browser', function () { - if (+(process.version.match(/^v(\d+)/) as RegExpMatchArray)[1] < 8) { - console.info('jsdom not supported, skipping base64-impl-browser...') - return - } - beforeEach(function () { const dom = new JSDOM(``, { url: 'https://example.com/', diff --git a/src/build/fs-impl-browser.spec.ts b/src/build/fs-impl-browser.spec.ts index 374b502f9..4ebe1fc99 100644 --- a/src/build/fs-impl-browser.spec.ts +++ b/src/build/fs-impl-browser.spec.ts @@ -3,10 +3,6 @@ import * as sinon from 'sinon' import { JSDOM } from 'jsdom' describe('fs/browser', function () { - if (+(process.version.match(/^v(\d+)/) as RegExpMatchArray)[1] < 8) { - console.info('jsdom not supported, skipping template-browser...') - return - } beforeEach(function () { const dom = new JSDOM(``, { url: 'https://example.com/foo/bar/', diff --git a/src/filters/array.ts b/src/filters/array.ts index 57a7d802d..bf16b5951 100644 --- a/src/filters/array.ts +++ b/src/filters/array.ts @@ -46,7 +46,7 @@ export function * sort_natural (this: FilterImpl, arr: T[], property?: string return yield * sortBy.call(this, arr, property, caseInsensitiveCompare) } -export const size = (v: string | any[]) => (v && v.length) || 0 +export const size = (v: string | any[]) => v?.length || 0 export function * map (this: FilterImpl, arr: Scope[], property: string): IterableIterator { const results = [] diff --git a/src/liquid-options.ts b/src/liquid-options.ts index 7ab1cbe2d..bd7a83497 100644 --- a/src/liquid-options.ts +++ b/src/liquid-options.ts @@ -204,11 +204,11 @@ export const defaultOptions: NormalizedFullOptions = { } export function normalize (options: LiquidOptions): NormalizedFullOptions { - if (options.hasOwnProperty('root')) { - if (!options.hasOwnProperty('partials')) options.partials = options.root - if (!options.hasOwnProperty('layouts')) options.layouts = options.root + if ('root' in options) { + if (!('partials' in options)) options.partials = options.root + if (!('layouts' in options)) options.layouts = options.root } - if (options.hasOwnProperty('cache')) { + if ('cache' in options) { let cache: LiquidCache | undefined if (typeof options.cache === 'number') cache = options.cache > 0 ? new LRU(options.cache) : undefined else if (typeof options.cache === 'object') cache = options.cache diff --git a/src/util/underscore.ts b/src/util/underscore.ts index c60a93ebb..4ee8d14b0 100644 --- a/src/util/underscore.ts +++ b/src/util/underscore.ts @@ -1,10 +1,9 @@ import { Drop } from '../drop/drop' export const toString = Object.prototype.toString +export const hasOwnProperty = Object.prototype.hasOwnProperty const toLowerCase = String.prototype.toLowerCase -export const hasOwnProperty = Object.hasOwnProperty - export function isString (value: any): value is string { return typeof value === 'string' } @@ -90,8 +89,7 @@ export function isUndefined (value: any): boolean { } export function isArray (value: any): value is any[] { - // be compatible with IE 8 - return toString.call(value) === '[object Array]' + return Array.isArray(value) } export function isArrayLike (value: any): value is any[] { diff --git a/tsconfig.json b/tsconfig.json index 0646fbcfe..d8718c62c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,8 +1,9 @@ { "compilerOptions": { - "target": "es6", - "module":"CommonJS", - "lib": ["es2015", "es2016", "es2017", "dom"], + "target": "ES2020", + "module":"ES2020", + "lib": ["ES2020", "dom"], + "moduleResolution": "node", "sourceMap": true, "outDir": "dist", "declaration": true,