mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-12 19:00:39 -07:00
* docs: add GitHub buttons and improve option docs
* chore: replace husky with prepush check
* docs: revamp homepage and switch to custom GitHub buttons
- Make the docs English-only by removing all zh-cn content, the language switcher UI, and related JS/config
- Rework homepage feature cards (Safe & Typed, Pure JavaScript, Shopify & Jekyll, Streaming) and refresh section colors/layout
- Replace buttons.github.io with custom Star/Sponsor buttons featuring a live star count and dark-mode support
- Drop the buttons.js script and tidy banner, header, footer, and share partials
Co-authored-by: Cursor <[email protected]>
* fix: restore tsconfig settings and changelog build
Re-add suppressImplicitAnyIndexErrors and downlevelIteration removed in
a75033e2c, which broke the rollup TypeScript build on CI. Drop zh-cn
changelog output now that translations were removed.
Co-authored-by: Cursor <[email protected]>
* fix: resolve TS errors without deprecated tsconfig options
Co-authored-by: Cursor <[email protected]>
---------
Co-authored-by: Cursor <[email protected]>
167 lines
3.7 KiB
JavaScript
167 lines
3.7 KiB
JavaScript
import { uglify } from 'rollup-plugin-uglify'
|
|
import typescript from 'rollup-plugin-typescript2'
|
|
import replace from 'rollup-plugin-replace'
|
|
import versionInjector from 'rollup-plugin-version-injector'
|
|
import { createRequire } from 'module'
|
|
|
|
const pkg = createRequire(import.meta.url)('./package.json')
|
|
const version = process.env.VERSION || pkg.version
|
|
const sourcemap = true
|
|
const banner = `/*
|
|
* liquidjs@${version}, https://github.com/harttle/liquidjs
|
|
* (c) 2016-${new Date().getFullYear()} harttle
|
|
* Released under the MIT License.
|
|
*/`
|
|
const treeshake = {
|
|
propertyReadSideEffects: false
|
|
}
|
|
const tsconfig = (target) => ({
|
|
check: true,
|
|
tsconfigOverride: {
|
|
include: ['src'],
|
|
exclude: ['test', 'benchmark'],
|
|
compilerOptions: {
|
|
target,
|
|
module: 'ES2015',
|
|
rootDir: 'src',
|
|
downlevelIteration: true
|
|
}
|
|
}
|
|
})
|
|
const versionInjection = versionInjector({
|
|
injectInComments: false,
|
|
injectInTags: {
|
|
fileRegexp: /\.(ts|js|html|css)$/,
|
|
tagId: 'VI',
|
|
dateFormat: 'mmmm d, yyyy HH:MM:ss'
|
|
},
|
|
packageJson: './package.json',
|
|
logLevel: 'info',
|
|
logger: console,
|
|
exclude: []
|
|
})
|
|
const input = './src/index.ts'
|
|
const browserFS = {
|
|
include: './src/liquid-options.ts',
|
|
delimiters: ['', ''],
|
|
'./fs/fs-impl': './build/fs-impl-browser'
|
|
}
|
|
const browserBase64 = {
|
|
include: './src/filters/base64.ts',
|
|
delimiters: ['', ''],
|
|
'./base64-impl': '../build/base64-impl-browser'
|
|
}
|
|
const browserCrypto = {
|
|
include: './src/filters/crypto.ts',
|
|
delimiters: ['', ''],
|
|
'./crypto-impl': '../build/crypto-impl-browser'
|
|
}
|
|
const browserStream = {
|
|
include: './src/emitters/index.ts',
|
|
delimiters: ['', ''],
|
|
'./streamed-emitter': '../build/streamed-emitter-browser'
|
|
}
|
|
const esmRequire = {
|
|
include: './src/fs/fs-impl.ts',
|
|
delimiters: ['', ''],
|
|
'./node-require': '../build/node-require.mjs'
|
|
}
|
|
|
|
const nodeCjs = {
|
|
output: [{
|
|
file: 'dist/liquid.node.js',
|
|
format: 'cjs',
|
|
banner
|
|
}],
|
|
external: ['path', 'fs', 'stream', 'crypto'],
|
|
plugins: [versionInjection, typescript(tsconfig('ES2020'))],
|
|
treeshake,
|
|
input
|
|
}
|
|
|
|
const nodeEsm = {
|
|
output: [{
|
|
file: 'dist/liquid.node.mjs',
|
|
format: 'esm',
|
|
banner
|
|
}],
|
|
external: ['path', 'fs', 'stream', 'crypto'],
|
|
plugins: [
|
|
versionInjection,
|
|
replace(esmRequire),
|
|
typescript(tsconfig('es6'))
|
|
],
|
|
treeshake,
|
|
input
|
|
}
|
|
|
|
const browserEsm = {
|
|
output: [{
|
|
file: 'dist/liquid.browser.mjs',
|
|
format: 'esm',
|
|
banner
|
|
}],
|
|
external: ['path', 'fs'],
|
|
plugins: [
|
|
versionInjection,
|
|
replace(browserFS),
|
|
replace(browserBase64),
|
|
replace(browserCrypto),
|
|
replace(browserStream),
|
|
typescript(tsconfig('es6'))
|
|
],
|
|
treeshake,
|
|
input
|
|
}
|
|
|
|
const browserUmd = {
|
|
output: [{
|
|
file: 'dist/liquid.browser.umd.js',
|
|
name: 'liquidjs',
|
|
format: 'umd',
|
|
sourcemap,
|
|
banner
|
|
}],
|
|
plugins: [
|
|
versionInjection,
|
|
replace(browserFS),
|
|
replace(browserBase64),
|
|
replace(browserCrypto),
|
|
replace(browserStream),
|
|
typescript(tsconfig('es5'))
|
|
],
|
|
treeshake,
|
|
input
|
|
}
|
|
|
|
const browserMin = {
|
|
output: [{
|
|
file: 'dist/liquid.browser.min.js',
|
|
name: 'liquidjs',
|
|
format: 'umd',
|
|
sourcemap,
|
|
banner
|
|
}],
|
|
plugins: [
|
|
versionInjection,
|
|
replace(browserFS),
|
|
replace(browserBase64),
|
|
replace(browserCrypto),
|
|
replace(browserStream),
|
|
typescript(tsconfig('es5')),
|
|
uglify()
|
|
],
|
|
treeshake,
|
|
input
|
|
}
|
|
|
|
const bundles = []
|
|
const env = process.env.BUNDLES || ''
|
|
if (env.includes('cjs')) bundles.push(nodeCjs)
|
|
if (env.includes('esm')) bundles.push(nodeEsm, browserEsm)
|
|
if (env.includes('umd')) bundles.push(browserUmd)
|
|
if (env.includes('min')) bundles.push(browserMin)
|
|
if (bundles.length === 0) bundles.push(nodeCjs, nodeEsm, browserEsm, browserUmd, browserMin)
|
|
|
|
export default bundles
|